Reporting

Need stats count snapshot at the beginning of every hour

samnew4598
Explorer

I have a query that finds what I need for the current time and saved it as a scheduled report. However, I also need the same statistics from my historical data but I can't seem to figure out a good way to execute it. 

The query:

index=red_cont
| dedup id sortby - _time
| where status=="blue"
| stats count by level

The query is run at the beginning of every hour which is great for current and future but how would I go about getting a snapshot count of every hour from a certain date such as "1/1/21" - till now.  I understand I can do this manually one hour at a time using the time picker and changing the latest hour but that would take a really long time. Thanks 


Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Bucket the events by hour and let stats sort them out for you.  Of course, this could be a lengthy query.

index=red_cont earliest=@y
| dedup id sortby - _time
| where status=="blue"
| bin span=1h _time
| stats count by _time, level

 

---
If this reply helps you, Karma would be appreciated.
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!

Community Content Calendar, September edition

Welcome to another insightful post from our Community Content Calendar! We're thrilled to continue bringing ...

Splunkbase Unveils New App Listing Management Public Preview

Splunkbase Unveils New App Listing Management Public PreviewWe're thrilled to announce the public preview of ...

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Are you leveraging automation to its fullest potential in your threat detection strategy?Our upcoming Security ...