Splunk Search
Highlighted

Use streamstats to calculate 7 days average but only display last 24 hours

Engager

I am using streamstats to calculate the average and standard deviation for past 7 days data by setting the timewindow to 7 days. However, I only want to display the last 1 hours data. For example, now is 8am, I want to have a table displaying the calculated average and standard deviation from 7am onwards, but each average should be based on past 7 days of data. However, when I set the timepicker to past hour, streamstats will only calculate average based on the 1 hour data.

Any help is much appreciated!

Tags (2)
0 Karma
Highlighted

Re: Use streamstats to calculate 7 days average but only display last 24 hours

SplunkTrust
SplunkTrust

To use seven days of data you need to set the timerangepicker to seven days. I'm guessing your search looks something like this?

index=foo sourcetype=bar | timechart span=1h count | streamstats window=168 avg(count)

If so, add | where _time = relative_time(now(), "-h@h") to only display the most recent complete hour.

0 Karma