<?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 stats by date_hour and by another field add zero count for hours with no events in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296798#M89536</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm working on a search to report the count of data by hour over any specified time period. At the moment i've got this on the tail of my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats dc(my_field)  by other_field, _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want this search to return the count of events grouped by hour and by "other_field" for alerting. And then compare it with data of the last day.&lt;/P&gt;

&lt;P&gt;But if the search returns no events for a given hour and other_field, that other_field doesn't appear at this hour in the resulting table.&lt;BR /&gt;
Is there a way to modify this to add 0's for the hours and other_fields with no events?&lt;/P&gt;

&lt;P&gt;I tried the "timechart" but it doesn't really do the job because I need to parse by "_time" AND by "other_field". It will create columns for each "other_field".&lt;/P&gt;

&lt;P&gt;Is there even a better way do do this?  This is for an alert where I want to compare the min between the 2 last result for each "other_field" and the result of the last day at the same hour and for the same "other_field".&lt;/P&gt;

&lt;P&gt;Thanks, Colin&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 16:53:39 GMT</pubDate>
    <dc:creator>Jonkiye</dc:creator>
    <dc:date>2020-09-29T16:53:39Z</dc:date>
    <item>
      <title>stats by date_hour and by another field add zero count for hours with no events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296798#M89536</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm working on a search to report the count of data by hour over any specified time period. At the moment i've got this on the tail of my search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats dc(my_field)  by other_field, _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want this search to return the count of events grouped by hour and by "other_field" for alerting. And then compare it with data of the last day.&lt;/P&gt;

&lt;P&gt;But if the search returns no events for a given hour and other_field, that other_field doesn't appear at this hour in the resulting table.&lt;BR /&gt;
Is there a way to modify this to add 0's for the hours and other_fields with no events?&lt;/P&gt;

&lt;P&gt;I tried the "timechart" but it doesn't really do the job because I need to parse by "_time" AND by "other_field". It will create columns for each "other_field".&lt;/P&gt;

&lt;P&gt;Is there even a better way do do this?  This is for an alert where I want to compare the min between the 2 last result for each "other_field" and the result of the last day at the same hour and for the same "other_field".&lt;/P&gt;

&lt;P&gt;Thanks, Colin&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 16:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296798#M89536</guid>
      <dc:creator>Jonkiye</dc:creator>
      <dc:date>2020-09-29T16:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: stats by date_hour and by another field add zero count for hours with no events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296799#M89537</link>
      <description>&lt;P&gt;Look into the &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Untable"&gt;untable&lt;/A&gt; command.  It can reformat your timechart results into a table format like you want.  Its counterpart, &lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.6.3/SearchReference/Xyseries"&gt;xyseries&lt;/A&gt;, reformats the other direction.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | timechart span=1h dc(my_field) as my_field by other_field | untable _time other_field my_field
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 19 Nov 2017 15:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296799#M89537</guid>
      <dc:creator>maciep</dc:creator>
      <dc:date>2017-11-19T15:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: stats by date_hour and by another field add zero count for hours with no events</title>
      <link>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296800#M89538</link>
      <description>&lt;P&gt;This is what I needed, thanks!&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 13:23:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/stats-by-date-hour-and-by-another-field-add-zero-count-for-hours/m-p/296800#M89538</guid>
      <dc:creator>Jonkiye</dc:creator>
      <dc:date>2017-11-20T13:23:55Z</dc:date>
    </item>
  </channel>
</rss>

