Splunk Search

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

SRF1LO
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

martin_mueller
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
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...