<?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: Need to display count having zero events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565223#M196919</link>
    <description>&lt;P&gt;Well, that's understandable firstly you select events using a set of constraints (in this case, possible index names), then you do a statistical operation on this set of events. Splunk in the | stats step doesn't know the original conditions. It only knows the events that have been supplied from the search.&lt;/P&gt;&lt;P&gt;If the filenames are known beforehand, you might prepare a static table using a lookup or an inline search with count=0 and then sum your results with those prepared earlier.&lt;/P&gt;&lt;P&gt;something like:&lt;/P&gt;&lt;PRE&gt;index=magic source IN ("D:\\show\\magic.log", "D:\\show\\magic_new.log", "D:\\show\\magic_old.log")&lt;BR /&gt;| stats count by source | append [ | makeresults &lt;BR /&gt;| eval _raw="D:\\show\\magic.log&lt;BR /&gt;D:\\show\\magic_new.log&lt;BR /&gt;D:\\show\\magic_old.log" &lt;BR /&gt;| multikv noheader=t &lt;BR /&gt;| rename Column_1 as source &lt;BR /&gt;| table source&lt;BR /&gt;| eval count=0 ] | stats sum(count) by source&lt;/PRE&gt;&lt;P&gt;Ugly as hell but should do.&lt;/P&gt;&lt;P&gt;If you have the filenames in a lookup you could just use inputlookup instead of all this consturction within [] (and use the lookup to generate constraints for the search as well- that way you have your search consistent.&lt;/P&gt;</description>
    <pubDate>Mon, 30 Aug 2021 10:40:59 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-08-30T10:40:59Z</dc:date>
    <item>
      <title>Need to display count having zero events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565220#M196918</link>
      <description>&lt;P&gt;I am having below search string and suppose the file "magic_new.log" has no events and the requirement is to show that as output&lt;BR /&gt;&lt;BR /&gt;index=magic&amp;nbsp; source IN ("D:\\show\\magic.log", "D:\\show\\magic_new.log", "D:\\show\\magic_old.log")&lt;BR /&gt;| stats count by source&lt;BR /&gt;| where count=0&lt;BR /&gt;&lt;BR /&gt;current output-&lt;BR /&gt;no results found&lt;BR /&gt;&lt;BR /&gt;expected output-&lt;BR /&gt;source&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; count&lt;BR /&gt;D:\show\magic_new.log&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;(Note: Tried multiple solutions suggested in the community but none worked)&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:20:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565220#M196918</guid>
      <dc:creator>prajwal_94</dc:creator>
      <dc:date>2021-08-30T10:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Need to display count having zero events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565223#M196919</link>
      <description>&lt;P&gt;Well, that's understandable firstly you select events using a set of constraints (in this case, possible index names), then you do a statistical operation on this set of events. Splunk in the | stats step doesn't know the original conditions. It only knows the events that have been supplied from the search.&lt;/P&gt;&lt;P&gt;If the filenames are known beforehand, you might prepare a static table using a lookup or an inline search with count=0 and then sum your results with those prepared earlier.&lt;/P&gt;&lt;P&gt;something like:&lt;/P&gt;&lt;PRE&gt;index=magic source IN ("D:\\show\\magic.log", "D:\\show\\magic_new.log", "D:\\show\\magic_old.log")&lt;BR /&gt;| stats count by source | append [ | makeresults &lt;BR /&gt;| eval _raw="D:\\show\\magic.log&lt;BR /&gt;D:\\show\\magic_new.log&lt;BR /&gt;D:\\show\\magic_old.log" &lt;BR /&gt;| multikv noheader=t &lt;BR /&gt;| rename Column_1 as source &lt;BR /&gt;| table source&lt;BR /&gt;| eval count=0 ] | stats sum(count) by source&lt;/PRE&gt;&lt;P&gt;Ugly as hell but should do.&lt;/P&gt;&lt;P&gt;If you have the filenames in a lookup you could just use inputlookup instead of all this consturction within [] (and use the lookup to generate constraints for the search as well- that way you have your search consistent.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 10:40:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565223#M196919</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-08-30T10:40:59Z</dc:date>
    </item>
    <item>
      <title>Re: Need to display count having zero events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565224#M196920</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Thanks!....but when I tried for similar kind of source with name as- "D:\\show\\*.log"&amp;nbsp; where * is dd-mm-yyyy&amp;nbsp; it gives multiple entries of output as-&lt;BR /&gt;&lt;BR /&gt;source&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sum(count)&lt;BR /&gt;D:\\show\\*.log&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0&lt;BR /&gt;D:\\show\\30-08-2021.log&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;&lt;BR /&gt;whereas required one is only-&lt;BR /&gt;D:\\show\\30-08-2021.log&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;BR /&gt;&lt;BR /&gt;do I need to make any changes in eval _raw, that you mentioned&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:15:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565224#M196920</guid>
      <dc:creator>prajwal_94</dc:creator>
      <dc:date>2021-08-30T11:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need to display count having zero events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565231#M196921</link>
      <description>&lt;P&gt;It won't work with glob patterns. It can't. Remember - as I wrote before - if you have your events as an output of the search (and want to do some further analysis like | stat) splunk doesn't know anymore what were the criteria you were searching by. So my walkaround was not letting you match filenames from "the input". It was just predicting the output.&lt;BR /&gt;You probably could do some magic to match with glob patterns or any other kind of match but that would involve either some kind of more complicated lookup matching or using some fancy evals.&lt;/P&gt;</description>
      <pubDate>Mon, 30 Aug 2021 11:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-to-display-count-having-zero-events/m-p/565231#M196921</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-08-30T11:52:18Z</dc:date>
    </item>
  </channel>
</rss>

