<?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 Can you help me write an if statement for the following condition? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421350#M121015</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I need to write an if statement for the following condition. I have two services in which status is shown by 0 or 1.&lt;BR /&gt;
0 is stop and 1 is running, It has two different sources. The alert should trigger when it is not running in both the sources i.e, (0,0) or (1,1).&lt;/P&gt;

&lt;P&gt;i tried using something like this but it does not work. How to rectify this query ?&lt;/P&gt;

&lt;P&gt;This is for (0,0)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if(((source="Primary_source" AND Status=0) AND (source="secondory_source" AND Status=0)),"Down", "Up")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is for both (0,0) and (1,1)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if((((source="Primary_source" AND Status=0) AND (source="secondory_source" AND Status=1))) OR ((source="Primary_source" AND Status=1) AND (source="secondory_source" AND Status=1)),"Down", "Up")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 03 Dec 2018 12:43:54 GMT</pubDate>
    <dc:creator>keishamtcs</dc:creator>
    <dc:date>2018-12-03T12:43:54Z</dc:date>
    <item>
      <title>Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421350#M121015</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I need to write an if statement for the following condition. I have two services in which status is shown by 0 or 1.&lt;BR /&gt;
0 is stop and 1 is running, It has two different sources. The alert should trigger when it is not running in both the sources i.e, (0,0) or (1,1).&lt;/P&gt;

&lt;P&gt;i tried using something like this but it does not work. How to rectify this query ?&lt;/P&gt;

&lt;P&gt;This is for (0,0)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if(((source="Primary_source" AND Status=0) AND (source="secondory_source" AND Status=0)),"Down", "Up")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is for both (0,0) and (1,1)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if((((source="Primary_source" AND Status=0) AND (source="secondory_source" AND Status=1))) OR ((source="Primary_source" AND Status=1) AND (source="secondory_source" AND Status=1)),"Down", "Up")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 03 Dec 2018 12:43:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421350#M121015</guid>
      <dc:creator>keishamtcs</dc:creator>
      <dc:date>2018-12-03T12:43:54Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421351#M121016</link>
      <description>&lt;P&gt;@keishamtcs&lt;/P&gt;

&lt;P&gt;If you have the latest event from the different source for the latest status, then you can try below search to get source wise status as a column. Here, you have different events from the different source.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH 
| dedup source | table source Status | transpose header_field=source 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you can add conditions as per your requireemtns.&lt;BR /&gt;
like,  for (0,0)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if(Primary_source=0 AND secondory_source=0,"Down", "Up")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For (1,1)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if(Primary_source=1 AND secondory_source=1,"Up", "Down")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;like that.&lt;/P&gt;

&lt;P&gt;My Sample Search is like below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval source="Primary_source",Status=0 | append [ | makeresults 
| eval source="secondory_source",Status=1 ] | dedup source | table source Status | transpose header_field=source 
| eval Application=if(Primary_source=0 AND secondory_source=0,"Down", "Up")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please let me know for more assistance.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 13:08:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421351#M121016</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-12-03T13:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421352#M121017</link>
      <description>&lt;P&gt;Hi Kamlesh,&lt;/P&gt;

&lt;P&gt;Thanks for the input..your query is using only one condition at a time. I would need need both the condition in the same search (0,0) and (1,1).&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 13:20:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421352#M121017</guid>
      <dc:creator>keishamtcs</dc:creator>
      <dc:date>2018-12-03T13:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421353#M121018</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
Can you please clarify the statement for up and down because I'm not sure I understand you correct.&lt;/P&gt;

&lt;P&gt;I see 4 possible variants, can you please approve (or disprove and fix this table):&lt;BR /&gt;
0,0 = Down&lt;BR /&gt;
0,1 = Up&lt;BR /&gt;
1,0=Up&lt;BR /&gt;
1,1=Down&lt;/P&gt;

&lt;P&gt;is it correct?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 13:37:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421353#M121018</guid>
      <dc:creator>sergeye</dc:creator>
      <dc:date>2018-12-03T13:37:18Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421354#M121019</link>
      <description>&lt;P&gt;@keishamtcs&lt;/P&gt;

&lt;P&gt;Yes, I have given you a sample search. Please try this one.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval Application=if((Primary_source=0 AND secondory_source=0) OR (Primary_source=1 AND secondory_source=1),"true", "false")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm not sure about what if (1,1) or (0,0),  so I have kept &lt;CODE&gt;true&lt;/CODE&gt; and &lt;CODE&gt;false&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;You can change it as per your requirement.&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 13:42:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421354#M121019</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-12-03T13:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421355#M121020</link>
      <description>&lt;P&gt;Hi If I understand you correct and you need an alert to trigger for both 0,0 and 1,1 conditions,&lt;BR /&gt;
I guess this is an easiest way (the actual query is only the last string):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval source="Primary_source",Status=1 
| append 
    [| makeresults 
    | eval source="Secondory_source",Status=1 ] 
| stats dc(Status) as Status | where Status = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;this will provide you a result only if both Statuses are 1 or both statuses are 0,&lt;BR /&gt;
and based on this you can create an alert.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 13:52:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421355#M121020</guid>
      <dc:creator>sergeye</dc:creator>
      <dc:date>2018-12-03T13:52:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421356#M121021</link>
      <description>&lt;P&gt;Yes..i did the tricked.  i dont see the option of accepting this answer. any idea where is it ?&lt;/P&gt;</description>
      <pubDate>Mon, 03 Dec 2018 15:35:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421356#M121021</guid>
      <dc:creator>keishamtcs</dc:creator>
      <dc:date>2018-12-03T15:35:20Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me write an if statement for the following condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421357#M121022</link>
      <description>&lt;P&gt;@keishamtcs&lt;/P&gt;

&lt;P&gt;Glad to help you. Please accept the answer. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Happy Splunking&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Dec 2018 13:18:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-write-an-if-statement-for-the-following/m-p/421357#M121022</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2018-12-11T13:18:46Z</dc:date>
    </item>
  </channel>
</rss>

