<?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: moving average query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313361#M93803</link>
    <description>&lt;P&gt;trendline command along with timechart might work here.&lt;/P&gt;

&lt;P&gt;Ex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype= customermetric customer!= Unknown   earliest=-3w |bin span=1h
_time | stats sum(trVol) AS volume_hour by user,_time| trendline sma504(volume_hour) AS sma_avg|your logic to caluculate 50 % diff btw hour count vs avg |... search filters
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 01 Jun 2017 18:28:12 GMT</pubDate>
    <dc:creator>Ravan</dc:creator>
    <dc:date>2017-06-01T18:28:12Z</dc:date>
    <item>
      <title>moving average query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313360#M93802</link>
      <description>&lt;P&gt;Hello - I m collecting some user metrics in below format. customer's trVol ( transactionvolume) &lt;/P&gt;

&lt;P&gt;2017-05-29 04:50:01,customer=ABC,trVol=2009,elapsedtimeAvg=175.7988&lt;BR /&gt;
2017-05-29 04:50:01,customer=DEF,trVol=500,elapsedtimeAvg=50.2&lt;/P&gt;

&lt;P&gt;Now, i need to identify those customers who is sending 50% or more transactions in last 1 hour compared to the  moving average of transaction volume  for last 3 weeks&lt;/P&gt;

&lt;P&gt;Can you help me with the SPL?&lt;/P&gt;

&lt;P&gt;sourcetype= customermetric customer!= Unknown &lt;BR /&gt;
 | streamstats window=6 global=f avg(trVol) as rollingavg by customer&lt;/P&gt;

&lt;P&gt;Customer metric is gathered every 10 minutes.&lt;/P&gt;</description>
      <pubDate>Mon, 29 May 2017 09:15:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313360#M93802</guid>
      <dc:creator>vw5qb73</dc:creator>
      <dc:date>2017-05-29T09:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: moving average query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313361#M93803</link>
      <description>&lt;P&gt;trendline command along with timechart might work here.&lt;/P&gt;

&lt;P&gt;Ex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype= customermetric customer!= Unknown   earliest=-3w |bin span=1h
_time | stats sum(trVol) AS volume_hour by user,_time| trendline sma504(volume_hour) AS sma_avg|your logic to caluculate 50 % diff btw hour count vs avg |... search filters
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 01 Jun 2017 18:28:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313361#M93803</guid>
      <dc:creator>Ravan</dc:creator>
      <dc:date>2017-06-01T18:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: moving average query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313362#M93804</link>
      <description>&lt;P&gt;Okay, so you have to calculate two pieces of information  -&lt;/P&gt;

&lt;P&gt;(1) what is the customer's moving average transaction volume per unit of time for the last 3 weeks&lt;BR /&gt;
(2) what is the customer's transaction volume for the most recent unit of time.&lt;/P&gt;

&lt;P&gt;Your best bet for efficiency will probably be to build a summary index, but let's ignore that for a moment.&lt;/P&gt;

&lt;P&gt;You apparently have the calculation for hourly average, so we drop in the 3-week average calculation (I think time_window works better than window for this matter)   and then compare... &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype= customermetric customer!= Unknown 
| streamstats time_window=3w avg(trVol) as rollingavg3w by customer
| streamstats window=6 global=f avg(trVol) as rollingavg1h by customer
| where rollingavg1h&amp;gt;1.5*rollingavg3w
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jun 2017 03:25:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313362#M93804</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-02T03:25:25Z</dc:date>
    </item>
    <item>
      <title>Re: moving average query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313363#M93805</link>
      <description>&lt;P&gt;What I haven't commented on is the "50% more" part of your query.  Unless your customers have VERY steady volumes, you would probably be better off calculating the 95th percentile (or something like that).  Run a few runs and compare the p95 to 1.5*avg and see what the shape of your data really is. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; sourcetype= customermetric customer!= Unknown 
 | streamstats time_window=3w avg(trVol) as W3avg  p95(trVol) as W3p95  by customer
 | streamstats window=6 global=f avg(trVol) as rollingavg1h by customer
 | where rollingavg1h&amp;gt;W3p95
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 02 Jun 2017 03:32:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/moving-average-query/m-p/313363#M93805</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-06-02T03:32:50Z</dc:date>
    </item>
  </channel>
</rss>

