<?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: Get hour count average over days in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73539#M18434</link>
    <description>&lt;P&gt;I finally find the answer by try and error.  Here is the corret search command&lt;/P&gt;

&lt;P&gt;sourcetype=”purchase” | stats count(customer_id) AS hit BY date_hour, date_mday | chart avg(hit) By date_hour&lt;/P&gt;

&lt;P&gt;On first stats, I also need to group by days of the month in order to supply data to the chart command.&lt;/P&gt;

&lt;P&gt;Is there any other way to improve it?&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 11:24:58 GMT</pubDate>
    <dc:creator>alextanght</dc:creator>
    <dc:date>2020-09-28T11:24:58Z</dc:date>
    <item>
      <title>Get hour count average over days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73538#M18433</link>
      <description>&lt;P&gt;I got data of each transaction with a customer_id in it&lt;/P&gt;

&lt;P&gt;If I want to know the daily average of count per hour, what search command should I use?&lt;BR /&gt;
e.g. day 1, 23-24hr is 1000 count, day 2 23-24 hr is 1200 count, then the average of these 2 day on 23-24 hr should be 1100 count&lt;/P&gt;

&lt;P&gt;I tried sourcetype=”purchase” | stats count(customer_id) AS hit BY date_hour | stats avg(hit) By date_hour&lt;/P&gt;

&lt;P&gt;However the result I get is a sum of count per hour over several days instead of an average.&lt;BR /&gt;
e.g. getting 23-24 hr is 2200 count instead of 1100 count as I want.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73538#M18433</guid>
      <dc:creator>alextanght</dc:creator>
      <dc:date>2020-09-28T11:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour count average over days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73539#M18434</link>
      <description>&lt;P&gt;I finally find the answer by try and error.  Here is the corret search command&lt;/P&gt;

&lt;P&gt;sourcetype=”purchase” | stats count(customer_id) AS hit BY date_hour, date_mday | chart avg(hit) By date_hour&lt;/P&gt;

&lt;P&gt;On first stats, I also need to group by days of the month in order to supply data to the chart command.&lt;/P&gt;

&lt;P&gt;Is there any other way to improve it?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:24:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73539#M18434</guid>
      <dc:creator>alextanght</dc:creator>
      <dc:date>2020-09-28T11:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour count average over days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73540#M18435</link>
      <description>&lt;P&gt;just like ur concept but change the parameter into date_wday, my search as follow:&lt;/P&gt;

&lt;P&gt;index= | timechart count(date_wday) as count span=1w|join _time [search index=dynadvisor | timechart dc(date_wday) as day_num span=1w]|eval avg=count/day_num&lt;/P&gt;

&lt;P&gt;hop it helpful&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:44:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73540#M18435</guid>
      <dc:creator>timpopxpop</dc:creator>
      <dc:date>2020-09-29T09:44:36Z</dc:date>
    </item>
    <item>
      <title>Re: Get hour count average over days</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73541#M18436</link>
      <description>&lt;P&gt;Something I would like to add to the answer of alextanght is that the command "date_...." is not consistent in most cases. It really depends on how splunk gets the timestamp from the data base you are using. It is best practice to use the "strftime" command to get the timestamp. So the query becomes as following&lt;/P&gt;

&lt;P&gt;sourcetype=”purchase” | eval time_hour = strftime(_time, "%H") | eval time_day = strftime(_time, "%D")  | stats count(customer_id) AS hit BY time_hour, time_day | chart avg(hit) By time_hour &lt;/P&gt;

&lt;P&gt;cheers,just a comment: date_hour and it's variations do not work well. It's more consistent to define for instance the hours of the day using: eval time_hour = strftime(_time, "%H"). You can do something similar for years,days,month,..... So the query will become as follows&lt;/P&gt;

&lt;P&gt;sourcetype=”purchase” | eval time_hour = strftime(_time, "%H") | eval time_day = strftime(_time, "%D") | stats count(customer_id) AS hit BY time_hour, time_day | chart avg(hit) By time_hour&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:52:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Get-hour-count-average-over-days/m-p/73541#M18436</guid>
      <dc:creator>siregensburg</dc:creator>
      <dc:date>2020-09-29T09:52:47Z</dc:date>
    </item>
  </channel>
</rss>

