<?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: Stats not returning zero counts in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Stats-not-returning-zero-counts/m-p/251329#M175874</link>
    <description>&lt;P&gt;(Assuming you want zero counts for host) &lt;BR /&gt;
You're going to have to either maintain a lookup of the hosts  you are interested in, or search for all the hosts in certain time range. If you're happy with a lookup, then you can run your query like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup interesting_hosts 
| fields host 
| join type=left host [ 
  search index=xxx earliest=-60m 
  | bucket _time span=3m 
  | stats count by _time host IP
  ] 
| fillnull count value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want something more dynamic, you can search for the hosts first over a longer time range than your final search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats earliest=-30d count WHERE index=xxx by host 
| fields host 
| join type=left host [ 
  search index=xxx earliest=-60m
  | bucket _time span=3m 
  | stats count by _time host IP
  ] 
| fillnull count value=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 30 Jan 2017 12:51:51 GMT</pubDate>
    <dc:creator>jplumsdaine22</dc:creator>
    <dc:date>2017-01-30T12:51:51Z</dc:date>
    <item>
      <title>Stats not returning zero counts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-not-returning-zero-counts/m-p/251328#M175873</link>
      <description>&lt;P&gt;index=xxx |bucket _time span=3m |stats count by _time host IP&lt;BR /&gt;
We are using the above stats command to get count instead of timechart just because we have two by clause fields. We need help in returning Zero count as part of stats iteslf if there is no data available. &lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 13:47:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-not-returning-zero-counts/m-p/251328#M175873</guid>
      <dc:creator>karthi2809</dc:creator>
      <dc:date>2017-01-24T13:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: Stats not returning zero counts</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Stats-not-returning-zero-counts/m-p/251329#M175874</link>
      <description>&lt;P&gt;(Assuming you want zero counts for host) &lt;BR /&gt;
You're going to have to either maintain a lookup of the hosts  you are interested in, or search for all the hosts in certain time range. If you're happy with a lookup, then you can run your query like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup interesting_hosts 
| fields host 
| join type=left host [ 
  search index=xxx earliest=-60m 
  | bucket _time span=3m 
  | stats count by _time host IP
  ] 
| fillnull count value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want something more dynamic, you can search for the hosts first over a longer time range than your final search&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats earliest=-30d count WHERE index=xxx by host 
| fields host 
| join type=left host [ 
  search index=xxx earliest=-60m
  | bucket _time span=3m 
  | stats count by _time host IP
  ] 
| fillnull count value=0
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 30 Jan 2017 12:51:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Stats-not-returning-zero-counts/m-p/251329#M175874</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2017-01-30T12:51:51Z</dc:date>
    </item>
  </channel>
</rss>

