Splunk Search

Rolling Averages

justx001
Explorer

I am having alot of trouble setting up rolling averages in Splunk. I would love to be able to overlay a 30, 60, 90 day trend line over my current trend line. this seems like a pretty standard function in analysis so I am sure im over looking some simple function? Is there documentation or guidance on how to set up rolling averages?

Tags (1)
1 Solution

skoelpin
SplunkTrust
SplunkTrust

You'll want to use streamstats to accomplish this

https://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Streamstats

Try something like this

<your base search> | timechart count span=30d | streamstats window=20 avg(count) as avgCount | fields _time avgCount [search <your base search> | timechart count span=60d | streamstats window=20 avg(count) as avgCount | fields _time avgCount]

View solution in original post

justx001
Explorer

Thank you very much for the quick reply, the reference and the example

skoelpin
SplunkTrust
SplunkTrust

You'll want to use streamstats to accomplish this

https://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Streamstats

Try something like this

<your base search> | timechart count span=30d | streamstats window=20 avg(count) as avgCount | fields _time avgCount [search <your base search> | timechart count span=60d | streamstats window=20 avg(count) as avgCount | fields _time avgCount]

aljohnson_splun
Splunk Employee
Splunk Employee

As an addendum to this fabulous answer, @justx001 you might want to check out the trendline command as well, it has weighted and exponential moving averages as well.


| ... base search
| timechart count span=1d
| trendline sma10(count) as ten_day_simple_moving_average, wma30(count) as month_weighted_moving_average, ema7(count) as week_exponential_moving_average

cmerriman
Super Champion

use |streamstats

https://docs.splunk.com/Documentation/Splunk/6.5.0/SearchReference/Streamstats

it's great for rolling averages. you can do multiple streamstats, one for the 30, 60, and 90 day windows.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...