<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Join/Subsearch - unsure which to use and why in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541763#M153397</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232002"&gt;@jb123213123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you want the number of session_ids, type=sandwich and type=drink for each name it's easy and it's possible to have with only one command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| stats dc(session_id) AS dc_session_id count(eval(type="sandwich")) AS n_sandwich count(eval(type="drink")) AS n_drink BY name&lt;/LI-CODE&gt;&lt;P&gt;if you want the details for each session_id is more complicate.&lt;/P&gt;&lt;P&gt;Do you need it?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Mon, 01 Mar 2021 14:25:05 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2021-03-01T14:25:05Z</dc:date>
    <item>
      <title>Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541762#M153396</link>
      <description>&lt;P&gt;My dataset is in a rather strange format. For a given 'event', I have numerous splunk entries all linked by a 'session_id'.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Within those sessions, there exist 2 fields I care about: name, request&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But these all exist independently on one of the numerous entries for a given session_id. For example, we could have 5 events for one session:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{session_id:15,&amp;nbsp; time: 1600, offset:1}&lt;/P&gt;&lt;P&gt;{session_id:15,&amp;nbsp; time: 1605,&amp;nbsp; name:bob}&lt;/P&gt;&lt;P&gt;{session_id:15,&amp;nbsp; time: 1607, type: sandwich}&lt;/P&gt;&lt;P&gt;{session_id:15,&amp;nbsp; time: 1608, type: drink}&lt;/P&gt;&lt;P&gt;{session_id:15,&amp;nbsp; time: 1610, offset: 2}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The first question is, for a given name - bob here - how do I do a search that would do the following:&lt;/P&gt;&lt;P&gt;Find all events with bob, count how many sandwich orders there were, count how many drink orders there were.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My attempt was to enumerate all session_ids for a given name, so for bob there could be session_ids of 5,7,10,15&lt;/P&gt;&lt;P&gt;Then for each session_id, do a subsearch specifying the session_id, and attempt to count the number of type:sandwich and type:drink fields there were. I couldn't work out how to get this to return to the main query in a good format.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:16:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541762#M153396</guid>
      <dc:creator>jb123213123</dc:creator>
      <dc:date>2021-03-01T14:16:30Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541763#M153397</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232002"&gt;@jb123213123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you want the number of session_ids, type=sandwich and type=drink for each name it's easy and it's possible to have with only one command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search
| stats dc(session_id) AS dc_session_id count(eval(type="sandwich")) AS n_sandwich count(eval(type="drink")) AS n_drink BY name&lt;/LI-CODE&gt;&lt;P&gt;if you want the details for each session_id is more complicate.&lt;/P&gt;&lt;P&gt;Do you need it?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:25:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541763#M153397</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-01T14:25:05Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541775#M153404</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Giuseppe,&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the quick response. That query definitely looks like its in the right direction, but is not showing any count for n_sandwich or n_drink.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It does seem to be counting the number of session_ids for each name though - just 0's for the other two events.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any ideas?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:34:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541775#M153404</guid>
      <dc:creator>jb123213123</dc:creator>
      <dc:date>2021-03-01T14:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541780#M153408</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232002"&gt;@jb123213123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;my search runs if the "type" field is already extracted, if not, you have to create a field extraction for it&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex "type:\s+(?&amp;lt;type&amp;gt;\w+)\}"&lt;/LI-CODE&gt;&lt;P&gt;to add to your search before the stats command.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:39:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541780#M153408</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-01T14:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541781#M153409</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Update - this is now working for one of the types but not the other. This is strange, however in the data i have noticed that "name" and "type: sandwich" are only ever present in the same single event.&amp;nbsp; another single event (for each session_id) contains the type:drink.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think this is causing issues as it cant count drink if it is looking for the name?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:51:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541781#M153409</guid>
      <dc:creator>jb123213123</dc:creator>
      <dc:date>2021-03-01T14:51:13Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541785#M153412</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232002"&gt;@jb123213123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Yes.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:52:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541785#M153412</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-01T14:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541789#M153414</link>
      <description>&lt;P&gt;How do I get around this? I can't edit the data.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i search on session_id, I could presumably count if the drinks field is present - can this be done through a subsearch into the main search?&lt;/P&gt;&lt;P&gt;Thanks very much for your help.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 14:56:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541789#M153414</guid>
      <dc:creator>jb123213123</dc:creator>
      <dc:date>2021-03-01T14:56:47Z</dc:date>
    </item>
    <item>
      <title>Re: Join/Subsearch - unsure which to use and why</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541797#M153418</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/232002"&gt;@jb123213123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;forget subsearches, Splunk isn't a procedural language!&lt;/P&gt;&lt;P&gt;You have to extract all the fields you need (in this case type).&lt;/P&gt;&lt;P&gt;So type could contain "sandwich" or "drink" and you count the occurrence of "sandwich" and "drink" using the count(eval(type="xxxx").&lt;/P&gt;&lt;P&gt;You can count in the same stats command both sandwich and drink.&lt;/P&gt;&lt;P&gt;I hope to be clear, otherwise, please share an example of your logs.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 01 Mar 2021 15:07:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Join-Subsearch-unsure-which-to-use-and-why/m-p/541797#M153418</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-03-01T15:07:53Z</dc:date>
    </item>
  </channel>
</rss>

