Alerting

What command to use to get the count without using transforming commands for the alert I created?

kollachandra
Path Finder

I have to create an alert based on the number of the events I need to define the criticality and include that in the subject of the alert. But, I am using eventstats command in my search. So, I am not able to use the fields in the alert subject or body. Please provide an alternative.

Base query

 | eval counter=case(
        (time_taken > 90000), "Count_90", 
    some switch cases
        (time_taken > 4000), "Count_4"
        ) 
    | eventstats count(eval(match(counter,"Count_90"))) as "Counter_90" count(eval(match(counter,"Count_60"))) as "Counter_60" count(eval(match(counter,"Count_30"))) as "Counter_30" count(eval(match(counter,"Count_20"))) as "Counter_20" count(eval(match(counter,"Count_15"))) as "Counter_15" count(eval(match(counter,"Count_10"))) as "Counter_10" count(eval(match(counter,"Count_4"))) as "Counter_4"
    | eval criticality = case(
        (Counter_90>5), "Critical-90s",
        Some switch cases
        (Counter_04>24), "Critical-4s",
        (Counter_4>11 AND Counter_4 <= 17), "Warning-4s"
        )
    | table criticality,Time,host,c_ip,cs_uri_stem,s_ip,s_port,sc_status,sc_substatus,time_taken
0 Karma
1 Solution

kollachandra
Path Finder

I think I got it. I removed the field name from the table. I added all the filed names that I needed to use them in the alert subject and it worked. Thank you!

View solution in original post

0 Karma

kollachandra
Path Finder

I think I got it. I removed the field name from the table. I added all the filed names that I needed to use them in the alert subject and it worked. Thank you!

0 Karma

somesoni2
Revered Legend

Based on what Splunk version you're using, you should be able to use fields from your search results in your Email Subject (see this https://docs.splunk.com/Documentation/Splunk/7.0.2/Alert/EmailNotificationTokens ). Since the criticality is a field in your search result, you should be able to include it using $result.criticality$. Please note only the first value for the specified field name from the first search result row will be added.

0 Karma

kollachandra
Path Finder

Our's is Splunk 7.0.2. I tried to add that way to the alert subject. But, no use. I am getting an null value. As I used eventstats is that the reason? Is there any other way to perform what I was doing using eventstats command?

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!

Your Feedback. Our Roadmap. Visit the PX Feedback Booth at .conf26

You use Splunk every day, come and help shape what's next.  Save Your Seat: Product-Focused Sessions at ...

Agentic SOC Triage: Investigating Splunk ES Notables with MCP Server and a Local LLM

The Problem: Too Many Alerts, Too Little Context Security operations teams running Splunk Enterprise Security ...

Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas

Watch Now Painting a Clearer Picture: Creating Cross-Domain Visibility with AI Canvas     Do you ever feel ...