Splunk Search

How to compare results of 2 periods?

jdonic
New Member

Hello, guys. I am struggling with my search in splunk and would appreciate any help.

 

Currently I have search that outputs the number of results for last hour and the hour before that.

 

index="xxx" sourcetype="xxx" environment="stage" earliest=-2h@h latest=-0h@h | bin _time span=1h
| stats count as mycount by _time

 

Now I would like to compare those two hours and create an alert only if the number of results from last hour is 100x smaller than from hour before that. Is that possible? How could I go about such conditional?

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try this.

index=xxx sourcetype=xxx environment="stage" earliest=-2h@h latest=-0h@h 
| bin _time span=1h
| stats count as mycount by _time
```Associate the mycount field from the previous event with the current event```
| streamstats window=2 first(mycount) as previous
| where mycount <= (previous / 100)
---
If this reply helps you, Karma would be appreciated.
0 Karma
Get Updates on the Splunk Community!

Data Management Digest – November 2025

  Welcome to the inaugural edition of Data Management Digest! As your trusted partner in data innovation, the ...

Splunk Mobile: Your Brand-New Home Screen

Meet Your New Mobile Hub  Hello Splunk Community!  Staying connected to your data—no matter where you are—is ...

Introducing Value Insights (Beta): Understand the Business Impact your organization ...

Real progress on your strategic priorities starts with knowing the business outcomes your teams are delivering ...