<?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: Search based on results of another search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/506166#M141622</link>
    <description>Please remember that there are row and time out limits for sub searches.... Sometimes those will hit if you are have two many rows in sub search. In those cases you must divide this search to two part e.g. first create lookup and then queries values from it on the actual search.&lt;BR /&gt;R. Ismo</description>
    <pubDate>Thu, 25 Jun 2020 14:44:57 GMT</pubDate>
    <dc:creator>isoutamo</dc:creator>
    <dc:date>2020-06-25T14:44:57Z</dc:date>
    <item>
      <title>Search based on results of another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/176411#M50666</link>
      <description>&lt;P&gt;Is it possible to perform a search on a whole dataset using a subset of terms from a previous search?&lt;/P&gt;

&lt;P&gt;For example, I have a search that yields all the failed transactions based on an event type:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=catalina* eventtype=search_fail
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I get back rows in the following form:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Mar 6, 2014 12:24:38 AM api.core.helper.LogHelper severe SEVERE: There was an error for search_id=530959
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;These rows all contain a &lt;CODE&gt;search_id&lt;/CODE&gt; number. I would like to then initiate a new search for any &lt;CODE&gt;search_id&lt;/CODE&gt; equal to these values, so that I can see all events leading up to these failures. Is that possible?&lt;/P&gt;

&lt;P&gt;I have tried various things like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=catalina* eventtype=search_fail | search search_id
sourcetype=catalina* eventtype=search_fail | search search_id=search_id
sourcetype=catalina* eventtype=search_fail [ search search_id ]
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But nothing seems to do what I am after.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2014 16:37:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/176411#M50666</guid>
      <dc:creator>lnetherton</dc:creator>
      <dc:date>2014-03-06T16:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Search based on results of another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/176412#M50667</link>
      <description>&lt;P&gt;Actually, I've figured it out. I needed to use the &lt;CODE&gt;fields&lt;/CODE&gt; operator to specifically select only the field that I want to use to search (&lt;CODE&gt;search_id&lt;/CODE&gt; in my case). I also misunderstood the way that subsearches work -- it is important to know that the subsearch  is evaluated first, and the result used to augment the outer search.&lt;/P&gt;

&lt;P&gt;This search term ended up doing what I wanted:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=catalina* [ search sourcetype=catalina* eventtype=search_fail | fields + search_id ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It was useful to know that the sub-search operation &lt;A href="http://docs.splunk.com/Documentation/Splunk/4.3.2/User/HowSubsearchesWork#Examples"&gt;implicitly appends&lt;/A&gt; a &lt;CODE&gt;| format&lt;/CODE&gt; operator on to the end. Combined with the &lt;CODE&gt;fields + search_id&lt;/CODE&gt; operation, the sub-search term is effectively expanded to something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=catalina* ( ( search_id="530959" ) OR ( search_id="529947" ) OR ( search_id="529938" ) OR ( search_id="529919" ) OR ( search_id="529793" ) OR ( search_id="529792" ) OR ( search_id="529568" ) OR ( search_id="529559" ) ) 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;which of course produces the output that I was after.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Mar 2014 17:03:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/176412#M50667</guid>
      <dc:creator>lnetherton</dc:creator>
      <dc:date>2014-03-06T17:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: Search based on results of another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/176413#M50668</link>
      <description>&lt;P&gt;Wanted to thank you for this.  I as able to use your example to solve a problem I had, and you also helped me understand how subsearches work!&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 20 Apr 2016 19:21:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/176413#M50668</guid>
      <dc:creator>butzowj</dc:creator>
      <dc:date>2016-04-20T19:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: Search based on results of another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/506129#M141616</link>
      <description>&lt;P&gt;You're the real MVP.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jun 2020 10:25:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/506129#M141616</guid>
      <dc:creator>slw07gdev</dc:creator>
      <dc:date>2020-06-25T10:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Search based on results of another search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/506166#M141622</link>
      <description>Please remember that there are row and time out limits for sub searches.... Sometimes those will hit if you are have two many rows in sub search. In those cases you must divide this search to two part e.g. first create lookup and then queries values from it on the actual search.&lt;BR /&gt;R. Ismo</description>
      <pubDate>Thu, 25 Jun 2020 14:44:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-based-on-results-of-another-search/m-p/506166#M141622</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-06-25T14:44:57Z</dc:date>
    </item>
  </channel>
</rss>

