<?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 How to count number of days a Store in is RED? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416971#M119989</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have created a table that displays Store number and its avg(cpu),avg(ram),avg(iowait) using stats command. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xyz OR sourcetype=abc
| stats avg(cpu) avg(.iowait) avg(ram) by source.store_num
| rename avg(cpu) as  Infrastructure 
| rename avg(iowait) as Application 
| rename avg(ram) as Database
| rename store_num as Store_Number
| eval State=case(Infrastructure&amp;gt;"90","Severe",Application&amp;gt;"90","Severe",Database&amp;gt;"90","Severe") 
| table Store_Number,Infrastructure,Application,Database, State
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to add a column which displays number of days the store is in red/severe. &lt;BR /&gt;
Also if all the three are in green than the counter has to reset and days becomes 0. &lt;/P&gt;

&lt;P&gt;Any ideas ???&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jun 2019 10:16:00 GMT</pubDate>
    <dc:creator>niks987</dc:creator>
    <dc:date>2019-06-10T10:16:00Z</dc:date>
    <item>
      <title>How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416971#M119989</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;I have created a table that displays Store number and its avg(cpu),avg(ram),avg(iowait) using stats command. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xyz OR sourcetype=abc
| stats avg(cpu) avg(.iowait) avg(ram) by source.store_num
| rename avg(cpu) as  Infrastructure 
| rename avg(iowait) as Application 
| rename avg(ram) as Database
| rename store_num as Store_Number
| eval State=case(Infrastructure&amp;gt;"90","Severe",Application&amp;gt;"90","Severe",Database&amp;gt;"90","Severe") 
| table Store_Number,Infrastructure,Application,Database, State
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I want to add a column which displays number of days the store is in red/severe. &lt;BR /&gt;
Also if all the three are in green than the counter has to reset and days becomes 0. &lt;/P&gt;

&lt;P&gt;Any ideas ???&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 10:16:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416971#M119989</guid>
      <dc:creator>niks987</dc:creator>
      <dc:date>2019-06-10T10:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416972#M119990</link>
      <description>&lt;P&gt;Dear @niks987 ,&lt;/P&gt;

&lt;P&gt;Try below query ..&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xyz OR sourcetype=abc
| eval Date=strftime(_time,"%d")
| dedup Date
| stats avg(cpu) as Infrastructure, avg(.iowait) as Application, avg(ram) as Database, count(Date) as Date by source.store_num
| rename store_num as Store_Number
| eval State=case(Infrastructure&amp;gt;90,"Severe",Application&amp;gt;90,"Severe",Database&amp;gt;90,"Severe")
| stats values(Infrastructure) as Infrastructure,values(Application) as Application,values(Database) as Database, sum(eval(if(Infrastructure&amp;gt;90 AND Application&amp;gt;90 AND Database&amp;gt;90, Date,0))) as Total_Days, values(State) as State by Store_Number
| table Store_Number,Infrastructure,Application,Database, State,Total_Days
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks  .. &lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 10:59:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416972#M119990</guid>
      <dc:creator>Shan</dc:creator>
      <dc:date>2019-06-10T10:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416973#M119991</link>
      <description>&lt;P&gt;Hi shankarananth,&lt;/P&gt;

&lt;P&gt;Thanks for your reply.&lt;/P&gt;

&lt;P&gt;I tried the query but it is not showing any results. Also if i am trying by splitting the query it only displays few store number.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 11:27:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416973#M119991</guid>
      <dc:creator>niks987</dc:creator>
      <dc:date>2019-06-10T11:27:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416974#M119992</link>
      <description>&lt;P&gt;Hi @niks987,&lt;/P&gt;

&lt;P&gt;Can you kindly share screen shot of complete query result and Query, result of splitting the query and splitting Query. &lt;BR /&gt;
If possible try to run the query line by line and find the Issue and see whether your getting the expected result in each line of the query.. &lt;/P&gt;

&lt;P&gt;Thanks   ..&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 11:38:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416974#M119992</guid>
      <dc:creator>Shan</dc:creator>
      <dc:date>2019-06-10T11:38:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416975#M119993</link>
      <description>&lt;P&gt;Hi shankarananth,&lt;/P&gt;

&lt;P&gt;I tried to run the query line by line, when i don't use eval Date, it displays all the stores but when i use eval Date it displays only 6 store. And if i add full query then it won't display anything.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 12:24:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416975#M119993</guid>
      <dc:creator>niks987</dc:creator>
      <dc:date>2019-06-10T12:24:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416976#M119994</link>
      <description>&lt;P&gt;@niks987,&lt;/P&gt;

&lt;P&gt;How about this query. This query will find noOfDays till it is being Severe for each different store_num. If today's State is not Severe then it will show noOfDays=0.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=xyz OR sourcetype=abc
| bin _time span=1h
| stats avg(cpu) as Infrastructure, avg(iowait) as Application, avg(ram) as Database by store_num, _time
| eval State=case(Infrastructure&amp;gt;"90","Severe",Application&amp;gt;"90","Severe",Database&amp;gt;"90","Severe")
| eval stateno = if(State="Severe",1,0)
| sort - _time
| streamstats min(stateno) as stateno by store_num
| stats avg(Infrastructure) as Infrastructure, avg(Application) as Application, avg(Database) as Database, sum(stateno) as noOfDays by store_num
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps!!!&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jun 2019 14:04:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416976#M119994</guid>
      <dc:creator>VatsalJagani</dc:creator>
      <dc:date>2019-06-10T14:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to count number of days a Store in is RED?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416977#M119995</link>
      <description>&lt;P&gt;So now the i have updated the query and it seems issue was due to dedup.&lt;/P&gt;

&lt;P&gt;sourcetype=xyz OR sourcetype=abc&lt;BR /&gt;
 | eval Date=strftime(_time,"%d")&lt;BR /&gt;
 | stats avg(cpu) as Infrastructure, avg(iowait) as Application, avg(.ram) as Database, values(Date) as Date by source.store_num&lt;BR /&gt;
 | rename source.store_num as Store_Number&lt;BR /&gt;
 | eval State=case(Infrastructure&amp;gt;90,"Severe",Application&amp;gt;90,"Severe",Database&amp;gt;90,"Severe")&lt;BR /&gt;
 | stats values(Infrastructure) as Infrastructure,values(Application) as Application,values(Database) as Database, sum(eval(if(Infrastructure&amp;gt;90 OR Application&amp;gt;90 OR Database&amp;gt;90, Date,0))) as Total_Days, values(State) as State by Store_Number&lt;BR /&gt;
 | stats if(Total_Days==0,0,count(Total_Days))&lt;BR /&gt;
  | table Store_Number,Infrastructure,Application,Database, State,Total_Days&lt;/P&gt;

&lt;P&gt;Using this is am getting all the store but the Total_Days column is adding all the dates i.e. if date is 9th and 10th June so its adding and displaying 19.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:52:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-count-number-of-days-a-Store-in-is-RED/m-p/416977#M119995</guid>
      <dc:creator>niks987</dc:creator>
      <dc:date>2020-09-30T00:52:23Z</dc:date>
    </item>
  </channel>
</rss>

