<?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: Can I perform If-Then-Else logic within a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366619#M164192</link>
    <description>&lt;P&gt;@johnny_goya, you should have a separate search to identify records to be appended to lookup file. It will be difficult to suggest exact query without looking at your existing SPL. Also make sure you use code button &lt;CODE&gt;(101010)&lt;/CODE&gt;, while posting your SPL so that special characters do not escape.&lt;/P&gt;</description>
    <pubDate>Thu, 28 Dec 2017 07:29:01 GMT</pubDate>
    <dc:creator>niketn</dc:creator>
    <dc:date>2017-12-28T07:29:01Z</dc:date>
    <item>
      <title>Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366609#M164182</link>
      <description>&lt;P&gt;Can I use if else for multiple search?&lt;/P&gt;

&lt;P&gt;Like this:&lt;BR /&gt;
index=* | eval result=if(field&amp;lt;=178000, [ search index=notable | regex status_label="Resolved" ] , [ search index=notable | regex status_label="Closed" ])&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:26:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366609#M164182</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2020-09-29T17:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366610#M164183</link>
      <description>&lt;P&gt;The query posted in question seems to be &lt;CODE&gt;if else&lt;/CODE&gt;, which you can implement in the following way:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;YourIndexName&amp;gt; OR status_label="Resolved" OR status_label="Closed"
| eval status_value=if(field&amp;lt;=178000, "Resolved","Closed")
| where status_label= status_value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you have multiple &lt;CODE&gt;if else conditions&lt;/CODE&gt;, you would have to use &lt;CODE&gt;case&lt;/CODE&gt; instead (PS: Just created three condition as an example adjust as per your need or use the one mentioned above with &lt;CODE&gt;if else&lt;/CODE&gt;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index==&amp;lt;YourIndexName&amp;gt; status_label="Open" OR status_label="Resolved" OR status_label="Closed"
| eval status_value=case(field&amp;lt;=86400,"Open", field&amp;gt;86400 AND field&amp;lt;=178000, "Resolved",true(),"Closed")
| where status_label= status_value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Refer to Splunk Documentation for evaluation functions &lt;CODE&gt;if&lt;/CODE&gt; and `case.&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#if.28X.2CY.2CZ.29"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#if.28X.2CY.2CZ.29&lt;/A&gt;&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#case.28X.2C.22Y.22.2C....29"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/ConditionalFunctions#case.28X.2C.22Y.22.2C....29&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 04:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366610#M164183</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-27T04:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366611#M164184</link>
      <description>&lt;P&gt;Hi niketnilay, thanks for the feedback.&lt;/P&gt;

&lt;P&gt;What I want to do is create an if statement that checks a field and if the if statement is false it updates the incident_review_lookup lookup.&lt;/P&gt;

&lt;P&gt;I do not know if my question was clearer.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:26:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366611#M164184</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2020-09-29T17:26:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366612#M164185</link>
      <description>&lt;P&gt;so you want if (field&amp;lt;=178000) then update result="Resolved" else update  incident_review_lookup lookup&lt;BR /&gt;
is my understanding correct?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:22:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366612#M164185</guid>
      <dc:creator>493669</dc:creator>
      <dc:date>2020-09-29T17:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366613#M164186</link>
      <description>&lt;P&gt;I want something like that.&lt;/P&gt;

&lt;P&gt;I tried to use the following query.&lt;/P&gt;

&lt;P&gt;| eval status_envio=if(tempo_status&amp;lt;=172800, "notificacao", [ search &lt;CODE&gt;notable&lt;/CODE&gt; | search status_label=Resolved | eval owner="Automatic" | eval urgency="informational" | eval status=5 | eval comment="Finished" | rex mode=sed field=comment "s/,/\n/g" | eval user="Automatic" | eval time=now() | outputlookup append=true incident_review_lookup ] )&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:22:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366613#M164186</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2020-09-29T17:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366614#M164187</link>
      <description>&lt;P&gt;Hi johnny_goya,&lt;BR /&gt;
Few questions i have. what are the fields in your lookup and which is the identical field in lookup and logs. Is "field" present in your logs?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 09:28:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366614#M164187</guid>
      <dc:creator>nikita_p</dc:creator>
      <dc:date>2017-12-27T09:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366615#M164188</link>
      <description>&lt;P&gt;I'm talking about the &lt;STRONG&gt;Enterprise Security&lt;/STRONG&gt; lookup incident review. This lookup stores the entire workflow of the generated events.&lt;/P&gt;

&lt;P&gt;The field was created by the time difference. [&lt;EM&gt;field = now () - last update of the event&lt;/EM&gt;]. &lt;/P&gt;

&lt;P&gt;I want the notable goes to status_label &lt;STRONG&gt;Closed&lt;/STRONG&gt; automatically after 2 days.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2017 22:53:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366615#M164188</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2017-12-27T22:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366616#M164189</link>
      <description>&lt;P&gt;Your search doesn't make sense as you have written it.  &lt;/P&gt;

&lt;P&gt;The flow of a splunk search starts at the top and flows down, affecting each event in the input set by one command at a time.  You are apparently trying to bring in a "flow" of data at the spot of your &lt;CODE&gt;if&lt;/CODE&gt; statement -- which does not work in splunk or any  other language.&lt;/P&gt;

&lt;P&gt;So, start over and rethink your requirements from the point of view of each individual event being processed.  Describe to yourself, and then us, what needs to happen to each one.  &lt;/P&gt;

&lt;P&gt;Please remember also, though, that when you output a record with append=t to a lookup, that all the prior records are still there, so it is NOT the same as updating an existing record.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 01:23:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366616#M164189</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-12-28T01:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366617#M164190</link>
      <description>&lt;P&gt;I've just posted the part of the query that I'm in doubt about.&lt;/P&gt;

&lt;P&gt;Do you know some way to do my task? I tried to use this search, but it does not execute if statement correctly. It always executes the subsearch regardless of the result of the if statement.&lt;/P&gt;

&lt;P&gt;I need to automate changing the status_label of a notable case if it has been in status_label resolved for more than 2 days.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 17:26:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366617#M164190</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2020-09-29T17:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366618#M164191</link>
      <description>&lt;P&gt;I'm trying to avoid using script&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 02:35:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366618#M164191</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2017-12-28T02:35:08Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366619#M164192</link>
      <description>&lt;P&gt;@johnny_goya, you should have a separate search to identify records to be appended to lookup file. It will be difficult to suggest exact query without looking at your existing SPL. Also make sure you use code button &lt;CODE&gt;(101010)&lt;/CODE&gt;, while posting your SPL so that special characters do not escape.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 07:29:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366619#M164192</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-12-28T07:29:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366620#M164193</link>
      <description>&lt;P&gt;Thanks for the support. Thanks for the advice.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 07:47:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366620#M164193</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2017-12-28T07:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can I perform If-Then-Else logic within a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366621#M164194</link>
      <description>&lt;P&gt;I think I've found a way to reach my goal.&lt;BR /&gt;
I will separate the querys and use summary index.&lt;BR /&gt;
Thanks for the support guys. Thanks for the advice.&lt;/P&gt;</description>
      <pubDate>Thu, 28 Dec 2017 07:48:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-I-perform-If-Then-Else-logic-within-a-search/m-p/366621#M164194</guid>
      <dc:creator>johnny_goya</dc:creator>
      <dc:date>2017-12-28T07:48:45Z</dc:date>
    </item>
  </channel>
</rss>

