<?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 Daily Average Event Count by Field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Daily-Average-Event-Count-by-Field/m-p/51547#M12468</link>
    <description>&lt;P&gt;Let's say I have a field called "host" and it can take the following values: host1, host2, host3.&lt;/P&gt;

&lt;P&gt;I'm having trouble writing a query which displays the number of hits each host had today and the average number of hits it has had over all time. A hit is defined as the host appearing in the field so if I had an event where host=host1 - that would count as a hit for host1 (essentially a count).&lt;/P&gt;

&lt;P&gt;The output would look something like this:&lt;/P&gt;

&lt;PRE&gt;
        Hits_Today    Average_Hits_over_all_time
host1        5              10
host2       12               3
host3       23              16
&lt;/PRE&gt;

&lt;P&gt;Any advice?&lt;/P&gt;</description>
    <pubDate>Tue, 01 Mar 2011 10:55:30 GMT</pubDate>
    <dc:creator>dan_growler</dc:creator>
    <dc:date>2011-03-01T10:55:30Z</dc:date>
    <item>
      <title>Daily Average Event Count by Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Daily-Average-Event-Count-by-Field/m-p/51547#M12468</link>
      <description>&lt;P&gt;Let's say I have a field called "host" and it can take the following values: host1, host2, host3.&lt;/P&gt;

&lt;P&gt;I'm having trouble writing a query which displays the number of hits each host had today and the average number of hits it has had over all time. A hit is defined as the host appearing in the field so if I had an event where host=host1 - that would count as a hit for host1 (essentially a count).&lt;/P&gt;

&lt;P&gt;The output would look something like this:&lt;/P&gt;

&lt;PRE&gt;
        Hits_Today    Average_Hits_over_all_time
host1        5              10
host2       12               3
host3       23              16
&lt;/PRE&gt;

&lt;P&gt;Any advice?&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2011 10:55:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Daily-Average-Event-Count-by-Field/m-p/51547#M12468</guid>
      <dc:creator>dan_growler</dc:creator>
      <dc:date>2011-03-01T10:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Daily Average Event Count by Field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Daily-Average-Event-Count-by-Field/m-p/51548#M12469</link>
      <description>&lt;P&gt;Well this will give you a table that's close to what you're looking for: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;&amp;lt;your search&amp;gt; | eval hit_today = if (_time &amp;lt; relative_time(now(), "@d"), 0, 1) | stats sum(hit_today) as Hits_Today count as Total by host&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Except that the last column is just the total count over the given timerange, not the average per day. &lt;/P&gt;

&lt;P&gt;If you run the search specifically over 'last 7 days',  and you divide 'Total' by 7 with another &lt;CODE&gt;eval&lt;/CODE&gt; command, you'll have the average count for those 7 days. &lt;/P&gt;

&lt;P&gt;If you need to calculate that daily average generically you can use the addinfo command to do it. &lt;/P&gt;

&lt;P&gt;see this question and answer which deals with similar issues. &lt;/P&gt;

&lt;P&gt;&lt;A href="http://answers.splunk.com/questions/2712/line-chart-comparing-yesterdays-result-with-todays-result-in-dashboard" rel="nofollow"&gt;http://answers.splunk.com/questions/2712/line-chart-comparing-yesterdays-result-with-todays-result-in-dashboard&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Mar 2011 13:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Daily-Average-Event-Count-by-Field/m-p/51548#M12469</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2011-03-01T13:28:53Z</dc:date>
    </item>
  </channel>
</rss>

