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!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

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