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!

Index This | Why did the turkey cross the road?

November 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  &#x1f680; Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Feel the Splunk Love: Real Stories from Real Customers

Hello Splunk Community,    What’s the best part of hearing how our customers use Splunk? Easy: the positive ...