<?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: Can you help me with a tstats count using lookup data? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410535#M118469</link>
    <description>&lt;P&gt;There will be nothing to count on if the sourcetype doesn't have any events there, that's just how Splunk works there. You can get the results you want with this though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup list.csv
| join type=left index, sourcetype [
| inputlookup list.csv
| map search="| tstats count where index=$index$ sourcetype=$sourcetype$ by index,sourcetype"]
| fillnull value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know what you think&lt;/P&gt;</description>
    <pubDate>Wed, 27 Feb 2019 16:45:15 GMT</pubDate>
    <dc:creator>tiagofbmm</dc:creator>
    <dc:date>2019-02-27T16:45:15Z</dc:date>
    <item>
      <title>Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410534#M118468</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;

&lt;P&gt;I have the below query trying to produce the event and host count for the last hour. The index &amp;amp; sourcetype is listed in the lookup CSV file. &lt;/P&gt;

&lt;P&gt;However this search does not show an index - sourcetype in the output if it has no data during the last hour.&lt;/P&gt;

&lt;P&gt;How do I use fillnull or any other method to show the event &amp;amp; host count as 0 when there is no data for that index/sourcetype?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count, dc(host) as hosts where 
    [| inputlookup List.csv ]
   by index, sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My List.csv is something like below, that lists down the index and sorcetypes.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index   sourcetype
----------  ----------------
win_idx  seclog
unx_idx  syslog
nw_idx   lblog
db_idx    dblog
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For eg: if &lt;CODE&gt;index=db_idx sourcetype=dblog&lt;/CODE&gt; count is 0, my current output using the above search is &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index   sourcetype   count   hosts
----------  ----------------  ---------  ----------
win_idx  seclog          1500     15
unx_idx  syslog          3000      50
nw_idx   lblog            1000      25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My expected output is:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index   sourcetype   count   hosts
----------  ----------------  ---------  ----------
win_idx  seclog          1500     15
unx_idx  syslog          3000      50
nw_idx   lblog            1000      25
db_idx    dblog           0            0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 15:01:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410534#M118468</guid>
      <dc:creator>ajith_sukumaran</dc:creator>
      <dc:date>2019-02-27T15:01:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410535#M118469</link>
      <description>&lt;P&gt;There will be nothing to count on if the sourcetype doesn't have any events there, that's just how Splunk works there. You can get the results you want with this though:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| inputlookup list.csv
| join type=left index, sourcetype [
| inputlookup list.csv
| map search="| tstats count where index=$index$ sourcetype=$sourcetype$ by index,sourcetype"]
| fillnull value=0
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Let me know what you think&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 16:45:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410535#M118469</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2019-02-27T16:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410536#M118470</link>
      <description>&lt;P&gt;Thanks. I tried this but the result is not as expected as the count value gets mismatched with the index - sourcetype.&lt;/P&gt;

&lt;P&gt;The first few index/ sourcetype shows the values as expected and fills data for those where no events. That's great.&lt;/P&gt;

&lt;P&gt;However remaining index/ sourcetype shows value 0 even if there is events present.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 18:07:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410536#M118470</guid>
      <dc:creator>ajith_sukumaran</dc:creator>
      <dc:date>2019-02-27T18:07:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410537#M118471</link>
      <description>&lt;P&gt;@ajith_sukumaran - Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | tstats count, dc(host) as hosts where 
[| inputlookup List.csv ]
by index, sourcetype| append[|inputlookup List.csv ]| fillnull value=0 count, hosts| stats sum(count) as count, sum(hosts) as hosts by index, sourcetype
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 27 Feb 2019 18:18:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410537#M118471</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-02-27T18:18:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410538#M118472</link>
      <description>&lt;P&gt;This search shows a count of 0 for pairs (sourcetype,index) that don't have any value. Adding the dc(host) will get your fourth column. Value mismatch on the count? tstats count by index,sourcetype can't be wrong, this runs &lt;CODE&gt;tstats count by index,sourcetype&lt;/CODE&gt;, how can it be right for some and wrong for others?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Feb 2019 18:21:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410538#M118472</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2019-02-27T18:21:25Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410539#M118473</link>
      <description>&lt;P&gt;yeah, I agree. This should have populated the actual counts and filled with null values. But I am not sure why the mismatch happens. Thanks for the search, I have the stats as required now.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 16:51:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410539#M118473</guid>
      <dc:creator>ajith_sukumaran</dc:creator>
      <dc:date>2019-03-06T16:51:27Z</dc:date>
    </item>
    <item>
      <title>Re: Can you help me with a tstats count using lookup data?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410540#M118474</link>
      <description>&lt;P&gt;Thanks for sharing this search. This is producing the result as required. &lt;/P&gt;</description>
      <pubDate>Wed, 06 Mar 2019 16:52:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-help-me-with-a-tstats-count-using-lookup-data/m-p/410540#M118474</guid>
      <dc:creator>ajith_sukumaran</dc:creator>
      <dc:date>2019-03-06T16:52:31Z</dc:date>
    </item>
  </channel>
</rss>

