<?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: Conditional searches in the same search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481213#M134848</link>
    <description>&lt;P&gt;not sure why not search for all and then eliminate  ....&lt;BR /&gt;
something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype=routes_devices OR sourcetype=router
 | table _time,host-name, reachability, name, sourcetype
 | eval result=if(reachability=="reachable",name,null())
 | search result=*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but maybe i am missing something&lt;/P&gt;</description>
    <pubDate>Wed, 18 Sep 2019 01:09:58 GMT</pubDate>
    <dc:creator>adonio</dc:creator>
    <dc:date>2019-09-18T01:09:58Z</dc:date>
    <item>
      <title>Conditional searches in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481210#M134845</link>
      <description>&lt;P&gt;Hello !&lt;/P&gt;

&lt;P&gt;Is there a way to do conditonal searches depending of the result of a first search ?&lt;BR /&gt;
I mean, here is an exemple : &lt;BR /&gt;
- A search command returns a table with a field containing an interesting value, for instance "reachable" or "not-reachable"&lt;BR /&gt;
- a second search command is executed only if the value is "reachable" is set in the first command&lt;BR /&gt;
- This second search should be run for each row of the table of the first command.&lt;/P&gt;

&lt;P&gt;In both commands, there are "eval" commands which are used for timestamp evaluations.&lt;BR /&gt;
Here is a simplified version of my query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype=routes_devices 
| table _time,host-name, reachability 
| eval result=if(reachability=="reachable",
[search index=* sourcetype=router fields name], "NOK")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is it possible to that kind of searches ? with the best performance possible.&lt;BR /&gt;
Thanks for your help !&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 06:34:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481210#M134845</guid>
      <dc:creator>julienlance</dc:creator>
      <dc:date>2019-09-16T06:34:48Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searches in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481211#M134846</link>
      <description>&lt;P&gt;@julienlance ,&lt;/P&gt;

&lt;P&gt;Looking at your requirement, most probably &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Map"&gt;map&lt;/A&gt; command should work for you.&lt;BR /&gt;
Apart from running the second search for each row, you can set a token in the first search for the desired search and use that token in the second search in map. So if the token is not set , then the second search will not run.&lt;/P&gt;

&lt;P&gt;e.g. &lt;CODE&gt;eval searchToken=case (reachability=="reachable",true())&lt;/CODE&gt; &lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2019 09:29:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481211#M134846</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-09-16T09:29:54Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searches in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481212#M134847</link>
      <description>&lt;P&gt;Thanks you @renjith.nair, this is a great clue, I will try to use it !&lt;BR /&gt;
Many thanks&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2019 16:50:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481212#M134847</guid>
      <dc:creator>julienlance</dc:creator>
      <dc:date>2019-09-17T16:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searches in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481213#M134848</link>
      <description>&lt;P&gt;not sure why not search for all and then eliminate  ....&lt;BR /&gt;
something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* sourcetype=routes_devices OR sourcetype=router
 | table _time,host-name, reachability, name, sourcetype
 | eval result=if(reachability=="reachable",name,null())
 | search result=*
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but maybe i am missing something&lt;/P&gt;</description>
      <pubDate>Wed, 18 Sep 2019 01:09:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481213#M134848</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2019-09-18T01:09:58Z</dc:date>
    </item>
    <item>
      <title>Re: Conditional searches in the same search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481214#M134849</link>
      <description>&lt;P&gt;The eval command you specified doesn't work, as the token can't be a boolean (splunk said). &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Sep 2019 13:34:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Conditional-searches-in-the-same-search/m-p/481214#M134849</guid>
      <dc:creator>julienlance</dc:creator>
      <dc:date>2019-09-20T13:34:09Z</dc:date>
    </item>
  </channel>
</rss>

