<?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 Combining Search Results By Passing Subsearch Values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417571#M120152</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Essentially, I am trying to join 2 or 3 log entries together linking them by a yet to be determined value (session ID) where the field I am searching for is not in every entry I am looking for.&lt;/P&gt;

&lt;P&gt;Breakdown:&lt;/P&gt;

&lt;P&gt;One Log Entry (AuthRs)&lt;BR /&gt;
- has sessionID that links the two entries&lt;BR /&gt;
- has a field value that I know of beforehand (UID)&lt;BR /&gt;
- has other field values that I need (status)&lt;/P&gt;

&lt;P&gt;Second Log Entry (One of 2 entries - either AuthRq or AuthRt - one of the two will exist)&lt;BR /&gt;&lt;BR /&gt;
- has the sessionID&lt;BR /&gt;
- doesn't have UID&lt;BR /&gt;
- has other field values I need (IP Address, UserAgent)&lt;/P&gt;

&lt;P&gt;Pseudo search:&lt;/P&gt;

&lt;P&gt;1       index=a sourcetype=a "AuthRs" UID=abc&lt;BR /&gt;
2       | table _time, UID, status, sessionID&lt;BR /&gt;
3       | join sessionID [ search sourcetype=a "AuthRq" OR "AuthRt" (need to pass sessionID from search here somehow) ]&lt;BR /&gt;
4       | table _time, UID, status, sessionID, IPAddress, useragent  (final table of values I want)&lt;/P&gt;

&lt;P&gt;I've also tried a search like this:&lt;/P&gt;

&lt;P&gt;Pseudo search 2&lt;BR /&gt;
index=a sourcetype=a (UID=123  AND "AuthRs") OR "AuthRs" OR "AuthRt"&lt;BR /&gt;
| stats list(_time) list(UID) list(status) list(IPAddress) list(userAgent) by sessionID&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;issue with this search is that the AuthRs and AuthRt searches are too large without narrowing down..but cant narrow down until I identify the sessionID would be found amongst all the entries &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I understand that subsearches are run first but not sure how to rewrite the search for the correct order . I have also heard &lt;/P&gt;

&lt;P&gt;The issue is that the line 1 search may identify multiple entries and i'd need to link all the events of search 1 to entries of search 2 by passing multiple session IDs if necessary. Without being able to pass the session ID, line 3 search conducts too many searches and drops results.  &lt;/P&gt;

&lt;P&gt;Maybe I can do an initial search just for the session IDs and then &lt;/P&gt;

&lt;P&gt;If i'm not clear, please let me know and I can try and explain further.&lt;/P&gt;</description>
    <pubDate>Tue, 16 Apr 2019 20:31:33 GMT</pubDate>
    <dc:creator>adamcoquim</dc:creator>
    <dc:date>2019-04-16T20:31:33Z</dc:date>
    <item>
      <title>Combining Search Results By Passing Subsearch Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417571#M120152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Essentially, I am trying to join 2 or 3 log entries together linking them by a yet to be determined value (session ID) where the field I am searching for is not in every entry I am looking for.&lt;/P&gt;

&lt;P&gt;Breakdown:&lt;/P&gt;

&lt;P&gt;One Log Entry (AuthRs)&lt;BR /&gt;
- has sessionID that links the two entries&lt;BR /&gt;
- has a field value that I know of beforehand (UID)&lt;BR /&gt;
- has other field values that I need (status)&lt;/P&gt;

&lt;P&gt;Second Log Entry (One of 2 entries - either AuthRq or AuthRt - one of the two will exist)&lt;BR /&gt;&lt;BR /&gt;
- has the sessionID&lt;BR /&gt;
- doesn't have UID&lt;BR /&gt;
- has other field values I need (IP Address, UserAgent)&lt;/P&gt;

&lt;P&gt;Pseudo search:&lt;/P&gt;

&lt;P&gt;1       index=a sourcetype=a "AuthRs" UID=abc&lt;BR /&gt;
2       | table _time, UID, status, sessionID&lt;BR /&gt;
3       | join sessionID [ search sourcetype=a "AuthRq" OR "AuthRt" (need to pass sessionID from search here somehow) ]&lt;BR /&gt;
4       | table _time, UID, status, sessionID, IPAddress, useragent  (final table of values I want)&lt;/P&gt;

&lt;P&gt;I've also tried a search like this:&lt;/P&gt;

&lt;P&gt;Pseudo search 2&lt;BR /&gt;
index=a sourcetype=a (UID=123  AND "AuthRs") OR "AuthRs" OR "AuthRt"&lt;BR /&gt;
| stats list(_time) list(UID) list(status) list(IPAddress) list(userAgent) by sessionID&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;issue with this search is that the AuthRs and AuthRt searches are too large without narrowing down..but cant narrow down until I identify the sessionID would be found amongst all the entries &lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I understand that subsearches are run first but not sure how to rewrite the search for the correct order . I have also heard &lt;/P&gt;

&lt;P&gt;The issue is that the line 1 search may identify multiple entries and i'd need to link all the events of search 1 to entries of search 2 by passing multiple session IDs if necessary. Without being able to pass the session ID, line 3 search conducts too many searches and drops results.  &lt;/P&gt;

&lt;P&gt;Maybe I can do an initial search just for the session IDs and then &lt;/P&gt;

&lt;P&gt;If i'm not clear, please let me know and I can try and explain further.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 20:31:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417571#M120152</guid>
      <dc:creator>adamcoquim</dc:creator>
      <dc:date>2019-04-16T20:31:33Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Search Results By Passing Subsearch Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417572#M120153</link>
      <description>&lt;P&gt;I think I figured it out. I did end up searching for just the session IDs and passing them to the search &lt;/P&gt;

&lt;P&gt;Pseudo code:&lt;BR /&gt;
index=a sourcetype=a "AuthRs" OR "AuthRs" OR "AuthRt"&lt;BR /&gt;
[ search sourcetype=a "AuthRs" UID=123 | fields sessionID ] &lt;BR /&gt;
| stats list(_time) list(UID) list(status) list(IPAddress) list(userAgent) by sessionID&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 13:11:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417572#M120153</guid>
      <dc:creator>adamcoquim</dc:creator>
      <dc:date>2019-04-17T13:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Combining Search Results By Passing Subsearch Values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417573#M120154</link>
      <description>&lt;P&gt;@adamcoquim If your problem is resolved, please accept the answer to help future readers.&lt;/P&gt;</description>
      <pubDate>Wed, 17 Apr 2019 13:18:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Combining-Search-Results-By-Passing-Subsearch-Values/m-p/417573#M120154</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2019-04-17T13:18:04Z</dc:date>
    </item>
  </channel>
</rss>

