<?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: How to use if condition along with count in a where condition? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366855#M108217</link>
    <description>&lt;P&gt;First, ditch &lt;CODE&gt;transaction&lt;/CODE&gt;; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= myindex source = "myapplog" application= "myapp"
| stats values(*) AS * range(transtime) AS response BY myeventId
| eval resStatus=if(response &amp;lt;= 0.01, "GREEN",if(ResponseTime&amp;lt;=0.02 ,"ABMBER","RED"))
| eval busEvents=case(match(path, "get\:\/products\/\success.html"),   "Products-Success",
                      match(path, "get\:\/products\/\remove.html"),    "Products-Remove",
                      match(path, "post\:\/products\/\purchase.html"), "Products-Purchase",
                      true(),                                          "Others")
| eventstats count(eval(resStatus="GREEN")) AS GREEN count(eval(resStatus="AMBER")) AS AMBER count(eval(resStatus="RED")) AS RED
| eval KEEPME=case(((RED&amp;gt;0)   AND     (resStatus="RED")),   "YES",
                   ((RED&amp;gt;0)   AND NOT (resStatus="RED")),    "NO",
                   ((AMBER&amp;gt;0) AND     (resStatus="AMBER")), "YES",
                   ((AMBER&amp;gt;0) AND NOT (resStatus="AMBER")),  "NO",
                   true(),                                  "YES")
| search KEEPME="YES"
| chart count over busEvents by resStatus
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 19 Mar 2017 02:15:07 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-03-19T02:15:07Z</dc:date>
    <item>
      <title>How to use if condition along with count in a where condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366854#M108216</link>
      <description>&lt;P&gt;Hi All, &lt;BR /&gt;
I need help with Splunk to find the count of the events. &lt;BR /&gt;
The base criteria was I will set of events from log file. I will group them based on myeventId and calculate the response time of each events, if the response time is not with in the predefined threshold value then i will show them in a graph along with the which operation has been falls under the category. Now my requirement was i have three status "GREEN","AMBER","RED". If any of the operation has at least one "RED" then I need to show only those events count.(no need to show "AMBER" and "RED"). If there are no events with "RED" and have atleast one "AMBER", then have to show only "AMBER) . If there are no "RED"&amp;amp;"AMBER" then only have to show "GREEN". I got stuck to filter these events. I am able to show all three events for each operation with my below search. Not able to figure it out with second requirement. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= myindex source = "myapplog" application= "myapp" | transaction myeventId startswith="start process" | eval endTransTime=(strptime(max(transtime), "%H:%M:%S)) | eval startTransTime= (strptime(min(transtime), "%H:%M:%S"))| eval response = (endTransTime-startTransTime)| eval resStatus =if(response &amp;lt;= 0.01, "GREEN",if(ResponseTime&amp;lt;=0.02 ,"ABMBER","RED")) | eval busEvents=case(match(path,"get\:\/products\/\success.html"),"Products-Success", match(path,"get\:\/products\/\remove.html"),"Products-Remove", match(path, "post\:\/products\/\purchase.html"), "Products-Purchase",1=1,"Others")| chart count over busEvents by resStatus
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 18 Mar 2017 15:30:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366854#M108216</guid>
      <dc:creator>bhavani_p</dc:creator>
      <dc:date>2017-03-18T15:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to use if condition along with count in a where condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366855#M108217</link>
      <description>&lt;P&gt;First, ditch &lt;CODE&gt;transaction&lt;/CODE&gt;; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index= myindex source = "myapplog" application= "myapp"
| stats values(*) AS * range(transtime) AS response BY myeventId
| eval resStatus=if(response &amp;lt;= 0.01, "GREEN",if(ResponseTime&amp;lt;=0.02 ,"ABMBER","RED"))
| eval busEvents=case(match(path, "get\:\/products\/\success.html"),   "Products-Success",
                      match(path, "get\:\/products\/\remove.html"),    "Products-Remove",
                      match(path, "post\:\/products\/\purchase.html"), "Products-Purchase",
                      true(),                                          "Others")
| eventstats count(eval(resStatus="GREEN")) AS GREEN count(eval(resStatus="AMBER")) AS AMBER count(eval(resStatus="RED")) AS RED
| eval KEEPME=case(((RED&amp;gt;0)   AND     (resStatus="RED")),   "YES",
                   ((RED&amp;gt;0)   AND NOT (resStatus="RED")),    "NO",
                   ((AMBER&amp;gt;0) AND     (resStatus="AMBER")), "YES",
                   ((AMBER&amp;gt;0) AND NOT (resStatus="AMBER")),  "NO",
                   true(),                                  "YES")
| search KEEPME="YES"
| chart count over busEvents by resStatus
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Mar 2017 02:15:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366855#M108217</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-19T02:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to use if condition along with count in a where condition?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366856#M108218</link>
      <description>&lt;P&gt;Hi Woodcock. Its working as expected :). Thanks much for your help.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Mar 2017 05:28:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-if-condition-along-with-count-in-a-where-condition/m-p/366856#M108218</guid>
      <dc:creator>bhavani_p</dc:creator>
      <dc:date>2017-03-19T05:28:13Z</dc:date>
    </item>
  </channel>
</rss>

