<?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: Listing and plotting total and average events by hour in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/619235#M215220</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/58318"&gt;@ejohn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I cannot test your search, but it should run:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count AS total by date_hour
| eval day=strftime(_time,"%m/%d/%Y")
| eventstats dc(date_mday) as daysNmonth
| eventstats count(_time) as TotalDays
| stats 
   dc(day) AS days 
   values(daysNmonth) AS daysNmonth 
   values(TotalDays) AS TotalDays 
   count 
   BY date_hour
| eval average=round(count/days,2)
| sort by date_hour
| rename count as SumOfEvents, days as NumOfEvents
| eval cumulative=round(SumOfEvents/TotalDays,2)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 02 Nov 2022 07:31:35 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2022-11-02T07:31:35Z</dc:date>
    <item>
      <title>How to list and plot total and average events by hour?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/617065#M214445</link>
      <description>&lt;DIV&gt;I'm trying to do something pretty straightforward, and have looked at&amp;nbsp; practically every "average" answer on Splunk Community, but no dice.&amp;nbsp; I want to compare total and average&amp;nbsp;&lt;SPAN&gt;webpage&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;h&lt;/SPAN&gt;&lt;SPAN&gt;its on a line chart.&amp;nbsp; I calculated and confirmed the standard (fillnull value=0) and cumulative (fillnull value=null) averages with the following:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV class="lia-indent-padding-left-30px"&gt;host....&lt;BR /&gt;| bin _time span=1h&lt;BR /&gt;| eval date_hour=strftime(_time, "%H")&lt;BR /&gt;| stats count as hits by date, date_hour&lt;BR /&gt;| xyseries date, date_hour, hits&lt;BR /&gt;| fillnull value=0&lt;BR /&gt;|appendpipe&lt;BR /&gt;&amp;nbsp; &amp;nbsp; [| untable date, date_hour, hits&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;| eventstats avg(hits) as avg_events by date_hour&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;| eval "Average Events"= avg_events&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;| xyseries date date_hour avg_events&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;| head 1&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;| eval date="Average Events"]&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;How do I plot hits and avg_events on a line chart by date_hour?&amp;nbsp; Also,&amp;nbsp; if there is less convoluted SPL to get the same results, I'd love to know that as well—because I think I found where Google ends.&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;DIV&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks!&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 14 Oct 2022 17:48:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/617065#M214445</guid>
      <dc:creator>ejohn</dc:creator>
      <dc:date>2022-10-14T17:48:55Z</dc:date>
    </item>
    <item>
      <title>Re: Listing and plotting total and average events by hour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/617094#M214455</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/58318"&gt;@ejohn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you grouped timestamps for hours using the bin command, you dont need the following commands, please try something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| eventstats count AS total
| bin _time span=1h
| stats values(total) AS total count BY _time
| eval average=count/total&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I didn't center your requirement, please share a sample of the desidered output&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 14 Oct 2022 06:28:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/617094#M214455</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-14T06:28:47Z</dc:date>
    </item>
    <item>
      <title>Re: Listing and plotting total and average events by hour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/617182#M214481</link>
      <description>&lt;DIV&gt;Ciao&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I've played around with the commands a bit, but still not getting the desired results.&amp;nbsp; I may not have explained well in my initial post, but I'm trying to get event counts and averages for a specific time range.&amp;nbsp; For example, if I have the following in my data:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;TABLE cellspacing="0" cellpadding="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date&lt;/TD&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;17&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;08-01-2022&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN class=""&gt;08-02-2022&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN class=""&gt;08-03-2022&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN class=""&gt;08-04-2022&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'd like to calculate the averages as follows:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;standard avg = Σ events/# of events&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;cumulative avg =&amp;nbsp;&lt;SPAN class=""&gt;Σ events/# of days&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date_hour&lt;/TD&gt;&lt;TD&gt;&lt;SPAN class=""&gt;Σ events&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN class=""&gt;# events&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;# days&lt;/TD&gt;&lt;TD&gt;standard avg&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;cumulative avg&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0.50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;0.16667&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN class=""&gt;17&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;4.5&lt;/TD&gt;&lt;TD&gt;1.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;The calculations would be executed separately so I can plot one line chart with Σ events vs standard avg and another with Σ events vs. cumulative avg.&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;The table for standard average would look like this:&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;date_hour&lt;/TD&gt;&lt;TD&gt;&lt;SPAN class=""&gt;Σ events&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;&lt;SPAN class=""&gt;# events&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;standard avg&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;01&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;SPAN class=""&gt;17&lt;/SPAN&gt;&lt;/TD&gt;&lt;TD&gt;9&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4.5&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the help!&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 17 Oct 2022 16:21:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/617182#M214481</guid>
      <dc:creator>ejohn</dc:creator>
      <dc:date>2022-10-17T16:21:43Z</dc:date>
    </item>
    <item>
      <title>Re: Listing and plotting total and average events by hour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/618057#M214806</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/58318"&gt;@ejohn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;ok, your first table could be created using this search:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| eventstats count AS total
| bin _time span=1h
| chart count OVER _time BY hits&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Instead to arrive to the final table, you could try something like this example:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=_internal 
| eventstats count AS total
| stats values(total) AS total dc(date_hour) AS date_hour count BY sourcetype
| eval average=round(count/total*100,2), cumulative=count/date_hour&lt;/LI-CODE&gt;&lt;P&gt;in your case, you should try something like this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;your_search&amp;gt;
| eventstats count AS total
| eval day=strftime(_time,"%m/%d/%Y")
| stats values(total) AS total dc(day) AS days count BY sourcetype
| eval average=round(count/total*100,2), cumulative=round(count/days,2)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sat, 22 Oct 2022 10:16:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/618057#M214806</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-10-22T10:16:27Z</dc:date>
    </item>
    <item>
      <title>Re: Listing and plotting total and average events by hour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/619219#M215212</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;You put me on the right track!&amp;nbsp; I modified what you provided to calculate the average:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count AS total by date_hour
| eval day=strftime(_time,"%m/%d/%Y")
| stats dc(day) AS days count BY date_hour
| eval average=round(count/days,2)
| sort by date_hour
| rename count as SumOfEvents, days as NumOfEvents&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used the syntax below separately to calculate the number of days in my selected date range.&amp;nbsp; So for the month of August, TotalDays will have a value of 31.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats dc(date_mday) as daysNmonth
| timechart sum(daysNmonth)
| stats count(_time) as TotalDays&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;I'm having trouble incorporating TotalDays with the first block of syntax to calculate:&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;SPAN&gt;cumulative=round(SumOfEvents&lt;/SPAN&gt;&lt;SPAN class=""&gt;/TotalDays,2)&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 00:26:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/619219#M215212</guid>
      <dc:creator>ejohn</dc:creator>
      <dc:date>2022-11-02T00:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Listing and plotting total and average events by hour</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/619235#M215220</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/58318"&gt;@ejohn&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I cannot test your search, but it should run:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eventstats count AS total by date_hour
| eval day=strftime(_time,"%m/%d/%Y")
| eventstats dc(date_mday) as daysNmonth
| eventstats count(_time) as TotalDays
| stats 
   dc(day) AS days 
   values(daysNmonth) AS daysNmonth 
   values(TotalDays) AS TotalDays 
   count 
   BY date_hour
| eval average=round(count/days,2)
| sort by date_hour
| rename count as SumOfEvents, days as NumOfEvents
| eval cumulative=round(SumOfEvents/TotalDays,2)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 07:31:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-and-plot-total-and-average-events-by-hour/m-p/619235#M215220</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-11-02T07:31:35Z</dc:date>
    </item>
  </channel>
</rss>

