Alerting

How do I get Splunk to generate an alert for multiple conditions?

Magnus_001
Explorer

Hello,

I am trying to monitor an application log and have Splunk generate an alert only when the  service_status = "disconnected" and  service_status="connected" entries are logged and the time between the two is greater than the span of 10 seconds OR if the Service_status = "disconnected" is the only entry being logged.   I've been experimenting with the transaction command but I am not getting the desired results.  Thanks in advance for any help with this.

Example log entries:

--- service is okay, do not generate an alert.---

9/2/2022 00:10:36.683   service_status = "disconnected"

9/2/2022 00:10:38.236  service_status="connected"

 

--- service is down, generate an alert.---

9/2/2022 00:10:40.683   service_status = "disconnected"

9/2/2022 00:10:51.736  service_status="connected"

 

--- service is down,  service_status="connected" event is missing,  generate an alert.---

9/2/2022 01:15:15.603   service_status = "disconnected"

 

Labels (1)
0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @Magnus_001,

you could use the transaction command but it's a very slow command, so I hint a different approach:

index=your_index (service_status="disconnected" OR service_status="connected")
| bin span=10s _time
| stats dc(service_status) AS service_status_count values(service_status) AS service_status BY _time
| where service_status_count=1 AND service_status="disconnected"

Ciao.

Giuseppe

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Leveraging Automated Threat Analysis Across the Splunk Ecosystem

Enhance Security Operations with Automated Threat Analysis in the Splunk EcosystemAre you leveraging ...

What Is Splunk? Here’s What You Can Do with Splunk

Hey Splunk Community, we know you know Splunk. You likely leverage its unparalleled ability to ingest, index, ...

Level Up Your .conf25: Splunk Arcade Comes to Boston

With .conf25 right around the corner in Boston, there’s a lot to look forward to — inspiring keynotes, ...