<?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: Show results of stats count when result is 0 in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515545#M144759</link>
    <description>&lt;LI-CODE lang="markup"&gt;| tstats count where index=A OR index=B OR index=C
| append [|makeresults 
| eval index=split("ABC",""), count=0 | mvexpand index| table index count]
| dedup index
| eval "Log Source"=case(index == "A", "indexA", index == "B", "indexB", index == "C", "IndexC")
| table "Log Source" count&lt;/LI-CODE&gt;&lt;P&gt;your sample is "index=A" , so it's difficult to use split() for actually log, I guess. you can do it.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Aug 2020 20:29:47 GMT</pubDate>
    <dc:creator>to4kawa</dc:creator>
    <dc:date>2020-08-21T20:29:47Z</dc:date>
    <item>
      <title>Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515532#M144751</link>
      <description>&lt;P&gt;I have a search using stats count but it is not showing the result for an index that has 0 results. There is two columns, one for Log Source and the one for the count.&amp;nbsp; &amp;nbsp;I'd like to&amp;nbsp; show the count of EACH index, even if there is 0 result.&amp;nbsp;&lt;/P&gt;&lt;P&gt;example&lt;/P&gt;&lt;P&gt;log source&amp;nbsp; count&lt;BR /&gt;A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20&lt;BR /&gt;B&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;BR /&gt;C&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=A or index=B or index=C 
| eval "Log Source"=case(index == "A", "indexA", index == "B", "indexB", index == "C", "IndexC")
| stats count by "Log Source"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 22:13:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515532#M144751</guid>
      <dc:creator>tromero3</dc:creator>
      <dc:date>2020-08-21T22:13:42Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515537#M144755</link>
      <description>&lt;P&gt;fillnull&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 19:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515537#M144755</guid>
      <dc:creator>jorjiana88</dc:creator>
      <dc:date>2020-08-21T19:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515538#M144756</link>
      <description>&lt;P&gt;already tried that, it doesn't work&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 19:19:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515538#M144756</guid>
      <dc:creator>tromero3</dc:creator>
      <dc:date>2020-08-21T19:19:14Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515545#M144759</link>
      <description>&lt;LI-CODE lang="markup"&gt;| tstats count where index=A OR index=B OR index=C
| append [|makeresults 
| eval index=split("ABC",""), count=0 | mvexpand index| table index count]
| dedup index
| eval "Log Source"=case(index == "A", "indexA", index == "B", "indexB", index == "C", "IndexC")
| table "Log Source" count&lt;/LI-CODE&gt;&lt;P&gt;your sample is "index=A" , so it's difficult to use split() for actually log, I guess. you can do it.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 20:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515545#M144759</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-21T20:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515549#M144760</link>
      <description>&lt;P&gt;Im confused about the split part, is that just combining the name of each index into one? (where you put&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;("ABC","")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;And why is that part needed?&lt;/P&gt;&lt;P&gt;My index names are actually longer of course and with dashes in the name such as "first-index", "second-index', etc&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also the first part of my search is longer not just the individual index. But more like&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=first-index event_type=security) OR (index=second-index rule_reason=IPblock)&lt;/LI-CODE&gt;&lt;P&gt;and so on...&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 21:01:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515549#M144760</guid>
      <dc:creator>tromero3</dc:creator>
      <dc:date>2020-08-21T21:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515550#M144761</link>
      <description>&lt;P&gt;You asked what to do if you don't have index ABC, so I answered, but the conditions are totally different.&lt;/P&gt;&lt;P&gt;I can't answer this. Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Aug 2020 21:06:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515550#M144761</guid>
      <dc:creator>to4kawa</dc:creator>
      <dc:date>2020-08-21T21:06:54Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515588#M144774</link>
      <description>&lt;P&gt;Have you considered appending a dummy event for each log and then subtracting 1 from every count?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Aug 2020 10:28:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515588#M144774</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2020-08-22T10:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515621#M144779</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/39047"&gt;@tromero3&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can hard code the log source list to the end of your results.&amp;nbsp; Using your initial example query something like this should work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=A or index=B or index=C 
| eval "Log Source"=case(index == "A", "indexA", index == "B", "indexB", index == "C", "IndexC")
| stats count by "Log Source"
 `comment("# ensure all log sources listed")`
| append [| makeresults | eval indexA="", indexB="", indexC="" | table indexA indexB indexC | transpose column_name="Log Source" ]
| stats max(count) AS count BY "Log Source"
| fillnull value=0 count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Aug 2020 06:53:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515621#M144779</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2020-08-23T06:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Show results of stats count when result is 0</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515883#M144875</link>
      <description>&lt;P&gt;wow that worked perfectly, thank you!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Aug 2020 20:08:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Show-results-of-stats-count-when-result-is-0/m-p/515883#M144875</guid>
      <dc:creator>tromero3</dc:creator>
      <dc:date>2020-08-24T20:08:44Z</dc:date>
    </item>
  </channel>
</rss>

