<?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 find out the count of zero for the multiple values of a field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397420#M115357</link>
    <description>&lt;P&gt;Can you give an example of your input?&lt;BR /&gt;
Because you would like to get the output divided by item_type but in the query you do not have any "by" condition.&lt;BR /&gt;
I would like to better understand what you have in input, the output you want is clear.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Aug 2018 07:02:28 GMT</pubDate>
    <dc:creator>andreacorvini</dc:creator>
    <dc:date>2018-08-10T07:02:28Z</dc:date>
    <item>
      <title>How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397417#M115354</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have a following query which gives the count of "zero".&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main item_type=television
| timechart count span=1m as item_count
| fillnull
| eval item_nonexistence = if(item_count &amp;lt;= 0, 1, null())
| stats sum(item_nonexistence) as item_count
| search item_count &amp;gt; 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It gives me the count if the condition, else no results. I have bunch of items (10) and i would like to get if count of "zero" is greater than 5.&lt;BR /&gt;
if count of zero is greater than 5 for item1, item2, item5, item8. It should produce me the results in the following way.&lt;/P&gt;

&lt;P&gt;item_type count&lt;BR /&gt;
item1   item1_missing&lt;BR /&gt;
item2   item2_missing&lt;BR /&gt;
item5   item5_missing&lt;BR /&gt;
item8   item8_missing&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:49:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397417#M115354</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T20:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397418#M115355</link>
      <description>&lt;P&gt;hmmmm, looks like you are filtering the &lt;CODE&gt;item_type&lt;/CODE&gt; in your search: &lt;CODE&gt;.... item_type = television&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Aug 2018 20:15:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397418#M115355</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2018-08-09T20:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397419#M115356</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/190478"&gt;@adonio&lt;/a&gt;, I have given it for an instance but actually the query does not contain any item_type. I want to sum the count of the events which are zero's and if the sum is greater than 5 then the results should look like below.&lt;/P&gt;

&lt;P&gt;item_type       event_count&lt;BR /&gt;
item1                   missing events are more than five for the selected time-range&lt;BR /&gt;
item2          1&lt;BR /&gt;
item3          2&lt;BR /&gt;
item4          missing events are more than five for the selected time-range&lt;/P&gt;

&lt;P&gt;Can you help me in getting the desired output? Please let me know if you require any additional information&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:50:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397419#M115356</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T20:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397420#M115357</link>
      <description>&lt;P&gt;Can you give an example of your input?&lt;BR /&gt;
Because you would like to get the output divided by item_type but in the query you do not have any "by" condition.&lt;BR /&gt;
I would like to better understand what you have in input, the output you want is clear.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 07:02:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397420#M115357</guid>
      <dc:creator>andreacorvini</dc:creator>
      <dc:date>2018-08-10T07:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397421#M115358</link>
      <description>&lt;P&gt;To rewrite your problem statement:  You want to know, for each item_type, whether for any five or more individual minutes across the search timeline, there were no events.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main item_type=*
| fields _time item_type
| bin _time span=1m 
| timechart span=1m count as item_count by item_type
| fillnull
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Up to this point, you had it right.  The &lt;CODE&gt;fields&lt;/CODE&gt; command we added is just explicitly telling splunk that those are the only fields needed for the remainder of the calculation, and special field &lt;CODE&gt;_time&lt;/CODE&gt; is there just for us to see, because the fields command doesn't remove hidden fields like &lt;CODE&gt;_time&lt;/CODE&gt; unless we specifically tell it to. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| untable _time item_type Item_count
| where item_count=0
| stats count as minute_count by item_type
| where minute_count &amp;gt; 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Untable is a special command that will take each record, and split it up into multiple records, each of which has the first named field (in this case &lt;CODE&gt;_time&lt;/CODE&gt;), and the name and value of one other field.  The name will go in the second parameter, and the value in the third parameter.  I could have said &lt;CODE&gt;untable _time foo bar&lt;/CODE&gt; and the field &lt;CODE&gt;foo&lt;/CODE&gt; would contain the item_type and &lt;CODE&gt;bar&lt;/CODE&gt; would contain the count for that time. &lt;/P&gt;

&lt;P&gt;So, for example, if your records were these two records...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; _time     drone   radio  television  typewriter 
(time1)     0         3          3          0 
(time2)     0         0          1          5 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;They would become these eight records...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; _time   item_type  Item_count

(time1)      drone       0
(time1)      radio       3
(time1)      television  3
(time1)      typewriter  0

(time2)      drone       0
(time2)      radio       0
(time2)      television  1
(time2)      typewriter  5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Passing through the &lt;CODE&gt;where&lt;/CODE&gt; test, these ones would pass...    &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; _time   item_type  Item_count

(time1)      drone       0
(time1)      typewriter  0

(time2)      drone       0
(time2)      radio       0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then the stats would put them together like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;item_type  minute_count
drone       2
radio       1
typewriter  1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And if any of them had more than five, they would pass the next test and give you your list.  You can then add any wording you want with another eval.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Aug 2018 05:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397421#M115358</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-11T05:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397422#M115359</link>
      <description>&lt;P&gt;I believe that this is the Sentinel Search problem discussed (with solution) here:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://conf.splunk.com/session/2015/conf2015-LookupTalk.pdf"&gt;https://conf.splunk.com/session/2015/conf2015-LookupTalk.pdf&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Aug 2018 20:50:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397422#M115359</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2018-08-11T20:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397423#M115360</link>
      <description>&lt;P&gt;@DalJeanis, Awesome!! Thanks a ton! This is exactly I was looking at.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Aug 2018 03:48:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397423#M115360</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2018-08-13T03:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397424#M115361</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/203121"&gt;@DalJeanis&lt;/a&gt;, I have a problem here, When the Item_count is zero for the selected time-range. The item_type is not being listed in the results.&lt;BR /&gt;
Though the count of zero's exists with item_type drone its not showing up.&lt;/P&gt;

&lt;P&gt;_time   item_type  Item_count&lt;BR /&gt;
 (time1)      drone         0&lt;BR /&gt;
(time1)      typewriter   0&lt;BR /&gt;
(time1)      radio            0&lt;BR /&gt;
 (time2)      drone          0&lt;BR /&gt;
 (time2)      typewriter  0&lt;BR /&gt;
 (time3)      drone          0&lt;BR /&gt;
 (time4)      drone          0&lt;/P&gt;

&lt;P&gt;The output looks like below:&lt;/P&gt;

&lt;P&gt;item_type  minute_count&lt;BR /&gt;
 radio               1&lt;BR /&gt;
 typewriter      1&lt;/P&gt;

&lt;P&gt;I would like to add the item_type with the Item_count as 1, when the Item_count are all zero's.&lt;/P&gt;

&lt;P&gt;Expected output for the above scenario:&lt;/P&gt;

&lt;P&gt;item_type  minute_count&lt;BR /&gt;
 radio               1&lt;BR /&gt;
 typewriter      2&lt;BR /&gt;
 drone              1&lt;/P&gt;

&lt;P&gt;Can you please help with this?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:54:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397424#M115361</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T20:54:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397425#M115362</link>
      <description>&lt;P&gt;Sure.  You need to ensure there is a record for each category for the time period immediately below your time period in question, before the chart command is run, then you throw that record away after the chart command.  Let's assume you have a csv file called mylist.csv with the list of item_type values you need.  Then something like this should work....&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=main item_type=*
 | fields _time item_type
 | bin _time span=1m 
 | append [ | inputcsv mylist.csv 
    | addinfo 
    | eval _time = info_min_time - 60 
    | table  _time item_type
    ] 

 | timechart span=1m count as item_count by item_type
 | fillnull
 | eventstats min(_time) as mintime 
 | where _time &amp;gt; mintime 
 | fields - mintime  

 | untable _time item_type Item_count
 | where item_count=0
 | stats count as minute_count by item_type
 | where minute_count &amp;gt; 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There might be a slightly less complicated way to use the csv, though.  Hmm.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     index=main item_type=*
     | fields _time item_type
     | bin _time span=1m 
     | timechart span=1m count as item_count by item_type
     | fillnull

     | untable _time item_type Item_count
     | appendpipe [
         | stats count as present by item_type
         | inputcsv append=t mylist.csv
         | stats count as dupcount by item_type
         | where dupcount=1 
         | eval flag = "missing" 
         | table  _time item_type
        ] 

 | where item_count=0
 | stats count as minute_count max(flag) as flag by item_type
 | where minute_count &amp;gt; 5 or isnotnull(flag)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Aug 2018 17:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397425#M115362</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-08-13T17:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to find out the count of zero for the multiple values of a field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397426#M115363</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/203121"&gt;@DalJeanis&lt;/a&gt;, Thanks for the reply! The query seems to be working only if there are records for each item_type but I would like the item_type to be updated with any of the values( 0 or 1) when there are no records found for the specific item_type.&lt;BR /&gt;
For example:&lt;BR /&gt;
Let's assume the count of zero for drone is 3, count of zero for typewriter is 2 and count of zero for radio is 0, i.e., radio has events for each minute for the selected time-range(15 Min) and television has no records for the selected time-range(15 Min) so I'm giving a dummy value as 15.&lt;BR /&gt;
I should get the following results when the condition is set as where count &amp;gt;= 2&lt;/P&gt;

&lt;P&gt;item_type   count&lt;BR /&gt;
drone              3 &lt;BR /&gt;
typewriter       2&lt;BR /&gt;
television        15&lt;/P&gt;

&lt;P&gt;Below it's returning this which is inappropriate.&lt;BR /&gt;
drone              3 &lt;BR /&gt;
typewriter       2&lt;BR /&gt;
radio                15&lt;BR /&gt;
television        15&lt;/P&gt;

&lt;P&gt;item_type &lt;STRONG&gt;radio&lt;/STRONG&gt; should not be in the results as it does not contain the value 0. Can you help on this?&lt;/P&gt;

&lt;P&gt;Query:&lt;/P&gt;

&lt;P&gt;index=main item_type=*&lt;BR /&gt;
| fields _time item_type&lt;BR /&gt;
| bin _time span=1m&lt;BR /&gt;
| timechart span=1m count as item_count by item_type useother=f&lt;BR /&gt;
| fillnull&lt;BR /&gt;
| untable _time item_type item_count&lt;BR /&gt;
| where item_count = 0&lt;BR /&gt;
| stats count by item_type&lt;BR /&gt;
| append&lt;BR /&gt;
    [| inputlookup Testing_Alerts&lt;BR /&gt;
    | fields + item_type&lt;BR /&gt;
    | stats count by item_type&lt;BR /&gt;
    | eval count = 0&lt;BR /&gt;
    | fields item_type count ]&lt;BR /&gt;
| dedup item_type&lt;BR /&gt;
| rename count as missing_item_count&lt;BR /&gt;
| eval missing_item_count = if(missing_item_count = 0, 15, missing_item_count)&lt;BR /&gt;
| where missing_item_count &amp;gt;= 2&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:52:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-find-out-the-count-of-zero-for-the-multiple-values-of-a/m-p/397426#M115363</guid>
      <dc:creator>bollam</dc:creator>
      <dc:date>2020-09-29T20:52:12Z</dc:date>
    </item>
  </channel>
</rss>

