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