Splunk Enterprise

How to create an alert when SuccessRate is Less than 40, and then it should trigger an email alert?

Ash1
Communicator

From the below query i want to get the alert when SuccessRate is Less than 40, it should trigger an email alert with customise message like "SuccessRate is less than 40 %, please take action." 

how can i do this??

index=app-code host_ip=34.23.234.12
|search activity=done
|eval result=if(like(responseHttp, "200"), "Success", "error")
|stats count (eval(result="Success")) as Total_Success, count(responseHttp) as Total
|eval Success_Count=(Total_Success/Total)*100.0
|stats avg(Success_Count) as SuccessRate
|where SuccessRate <40


Labels (1)
0 Karma

woodcock
Esteemed Legend

You are already there, just set it as an alert with "Number of Results is greater than 0":

index="_internal" AND sourcetype="splunkd_access" AND Http
| rex "HTTP\/\S+\"\s+(?<responseHttp>\d\d\d)\s+"
| eval result=if(like(responseHttp, "200"), "Success", "error")
| stats count(eval(result="Success")) AS Total_Success, count(responseHttp) AS Total
| eval Success_Count=(Total_Success/Total)*100.0
| stats avg(Success_Count) AS SuccessRate
| where SuccessRate<40
| eval message="SuccessRate is low, please take action."

inventsekar
SplunkTrust
SplunkTrust

Hi @Ash1 please check this Alerts documentation.. you can look for "tokens" in this pdf file..

let us know if you are stuck, we can help you.. thanks.. 

https://docs.splunk.com/Documentation/Splunk/9.0.2/Alert/Aboutalerts

https://docs.splunk.com/Documentation/Splunk/9.0.4/Alert/Emailnotification

https://docs.splunk.com/Documentation/Splunk/latest/Alert/Setupalertactions

 

 

0 Karma

Ash1
Communicator

Hi @inventsekar  here the message i want to display in mail is static message which is not mentioned in my logs to use tokens.

At the end of my query i tried to use

|Eval SuccesRate=if(Success rate<40, "SuccessRate is low, please take action." )

But this is not working 

 

 

0 Karma

inventsekar
SplunkTrust
SplunkTrust
index=app-code host_ip=34.23.234.12
|search activity=done
|eval result=if(like(responseHttp, "200"), "Success", "error")
|stats count (eval(result="Success")) as Total_Success, count(responseHttp) as Total
|eval Success_Count=(Total_Success/Total)*100.0
|stats avg(Success_Count) as SuccessRate
|where SuccessRate <40

you mean, this search query is not working ah.. pls run this search query line by line, so that you can understand which part of this query didnt work.. 

0 Karma

Ash1
Communicator

Hi @inventsekar , my query is working but i want to display customised message in the email when success percentage is less than 40.

For that i tried adding the below eval to the end of my query, but this message is not showing up when i run in splunk.

|Eval SuccesRate=if(Success rate<40, "SuccessRate is low, please take action." )

 

How can I do it???

0 Karma

inventsekar
SplunkTrust
SplunkTrust

1). Ur query is working fine. Good..

2). Is the the alerts working as expected?

3). When alert fire, you want the subject line or the body.. which one you want to customize

4) did you try the tokens(  $variable$ ) idea.. 

0 Karma
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...

Design, Compete, Win: Submit Your Best Splunk Dashboards for a .conf26 Pass

Hello Splunkers,  We’re excited to kick off a Splunk Dashboard contest! We know that dashboards are a primary ...

May 2026 Splunk Expert Sessions: Security & Observability

Level Up Your Operations: May 2026 Splunk Expert Sessions Whether you are refining your security posture or ...