Splunk Search

How to compare previous data and alert if result over 5 percencet

dhavamanis
Builder

We have monthly data for each SBU and we want to setup an alert if any total increase more than 5% for up coming month.

index=mydata | bin span=1mon _time | stats sum(total) as Total_Val by _time, SBU | sort +SBU -_time

Can you please help us to write a Splunk query to filter if any total increase more than 5% comparing with previous month.

Note: We have more than 50 SBU.

0 Karma
1 Solution

dhavamanis
Builder

Streamstats works fine,

....| stats sum(total) as total by _time, SBU | sort +SBU -_time|table _time, SBU, total | streamstats current=f window=1 first(total) as prev by SBU |eval deltaval=total - prev | eval diffp=deltaval/total*100 | where diffp>5

View solution in original post

0 Karma

dhavamanis
Builder

Streamstats works fine,

....| stats sum(total) as total by _time, SBU | sort +SBU -_time|table _time, SBU, total | streamstats current=f window=1 first(total) as prev by SBU |eval deltaval=total - prev | eval diffp=deltaval/total*100 | where diffp>5

0 Karma

Sukisen1981
Champion

Any reason why streamstats , prev value is not woking?

somesoni2
SplunkTrust
SplunkTrust

That would be the way to go for this use case.

0 Karma

dhavamanis
Builder

Thanks. Initially tried with delta. but streamstats works for this case.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...