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!

Wondering How to Build Resiliency in the Cloud?

IT leaders are choosing Splunk Cloud as an ideal cloud transformation platform to drive business resilience,  ...

Updated Data Management and AWS GDI Inventory in Splunk Observability

We’re making some changes to Data Management and Infrastructure Inventory for AWS. The Data Management page, ...

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...