<?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: How to calculate a running average of events by a user? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408054#M117817</link>
    <description>&lt;P&gt;Try the following: add _time to the by clause of your initial stats, to generate hourly counts for each user. Then use eventstats to calculate historic average by user.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=some_db sourcetype=syslog_tranactions
|bin _time span=1h
| stats count as hourly_count by created_by,_time
| eventstats avg(hourly_count) as historic_avg by created_by
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need that historic_avg to be a running avg (ie. only based on the previous hours, rather than calculating 1 avg. over all your search results), you could use a similar query but using streamstats instead of eventstats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=some_db sourcetype=syslog_tranactions
|bin _time span=1h
| stats count as hourly_count by created_by,_time
| sort _time
| streamstats avg(hourly_count) as historic_avg by created_by
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 29 Jun 2018 13:48:21 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2018-06-29T13:48:21Z</dc:date>
    <item>
      <title>How to calculate a running average of events by a user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408053#M117816</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
I am trying to write a query where I can monitor transactions/hr/user.    I would like an output where I have the hourly count and historic hourly average.&lt;/P&gt;

&lt;P&gt;I started with this, for past 24 hours, to look for users above a 10000 events per hour ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=some_db sourcetype=syslog_tranactions |bin _time span=1h | stats count by created_by | WHERE count &amp;gt; 10000
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But now I was asked to get a baseline of average transactions per hour per user as a running average as a separate output column&lt;/P&gt;

&lt;P&gt;Something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;User, Hourly Count, Historic Ave

Jon, 125, 140
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I am hoping someone could point me in the right direction as I peruse the documentation.&lt;/P&gt;

&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 13:38:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408053#M117816</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-06-29T13:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a running average of events by a user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408054#M117817</link>
      <description>&lt;P&gt;Try the following: add _time to the by clause of your initial stats, to generate hourly counts for each user. Then use eventstats to calculate historic average by user.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=some_db sourcetype=syslog_tranactions
|bin _time span=1h
| stats count as hourly_count by created_by,_time
| eventstats avg(hourly_count) as historic_avg by created_by
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need that historic_avg to be a running avg (ie. only based on the previous hours, rather than calculating 1 avg. over all your search results), you could use a similar query but using streamstats instead of eventstats:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=some_db sourcetype=syslog_tranactions
|bin _time span=1h
| stats count as hourly_count by created_by,_time
| sort _time
| streamstats avg(hourly_count) as historic_avg by created_by
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jun 2018 13:48:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408054#M117817</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-29T13:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a running average of events by a user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408055#M117818</link>
      <description>&lt;P&gt;thank you for the answer.&lt;/P&gt;

&lt;P&gt;If I want to put a threshold like,  "| WHERE count &amp;gt; 1000"&lt;/P&gt;

&lt;P&gt;is this the best way?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=some_db sourcetype=syslog_tranactions
 |bin _time span=1h
 | stats count as hourly_count by created_by,_time
|WHERE hourly_count&amp;gt;1000
 | sort _time
 | streamstats avg(hourly_count) as historic_avg by created_by
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 29 Jun 2018 14:06:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408055#M117818</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-06-29T14:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a running average of events by a user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408056#M117819</link>
      <description>&lt;P&gt;That depends a bit on what exactly you want to achieve with that threshold. You may want to put it all the way at the bottom, such that the historic avg is still calculated accurately. In your suggestion, hours with small counts will be ignored for the historic avg.&lt;/P&gt;

&lt;P&gt;Also: do you want to filter out low hourly counts. Or do you want to completely ignore users with a low total count? For that latter case, you would need to calculate that total first.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 14:14:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408056#M117819</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-06-29T14:14:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to calculate a running average of events by a user?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408057#M117820</link>
      <description>&lt;P&gt;Thank you, that makes sense.  I will run a few tests and as another question if I get stuck. Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 29 Jun 2018 14:22:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-calculate-a-running-average-of-events-by-a-user/m-p/408057#M117820</guid>
      <dc:creator>Log_wrangler</dc:creator>
      <dc:date>2018-06-29T14:22:44Z</dc:date>
    </item>
  </channel>
</rss>

