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
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!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...