Splunk Search

Compare Current Field Value to 24 Hour Average

mcg_connor
Path Finder

So I am currently trying to compare the average value of a field is using 7 days of events to what the value is currently. If the current value is greater than 3 times that average I want it to send an alert. Currently I am able to do the first part that finds the average count of the field but I am unable to figure out how to compare that to the current field value.

index=db  sourcetype="dbmetrics" earliest=-7d
| stats avg(db_connections) as DBConnectionsAvg  by database

Sorry if the explanation on this is messy, pretty new to Splunk

0 Karma
1 Solution

mayurr98
Super Champion

Try this :

index=db sourcetype="dbmetrics" earliest=-7d 
| stats avg(db_connections) as DBConnectionsAvg latest(db_connections) as DBConnectionsCurrent by database 
| where 3*DBConnectionsAvg<DBConnectionsCurrent

View solution in original post

mayurr98
Super Champion

Try this :

index=db sourcetype="dbmetrics" earliest=-7d 
| stats avg(db_connections) as DBConnectionsAvg latest(db_connections) as DBConnectionsCurrent by database 
| where 3*DBConnectionsAvg<DBConnectionsCurrent

mcg_connor
Path Finder

Didn't know about the latest command. Thanks!

0 Karma
Get Updates on the Splunk Community!

What's new in Splunk Cloud Platform 9.1.2312?

Hi Splunky people! We are excited to share the newest updates in Splunk Cloud Platform 9.1.2312! Analysts can ...

What’s New in Splunk Security Essentials 3.8.0?

Splunk Security Essentials (SSE) is an app that can amplify the power of your existing Splunk Cloud Platform, ...

Let’s Get You Certified – Vegas-Style at .conf24

Are you ready to level up your Splunk game? Then, let’s get you certified live at .conf24 – our annual user ...