Alerting

How to use substr in an alert email subject?

sholom
Engager

I'd like to include the first 20 characters of a variable in an alert email subject. I've tried substr($result.EX$,1,20) but that ends up including the static text "substr" as well as the entire variable value along with the parenthesis and 1,20.

Is the correct way to wrap it all in $? - $substr($result.EX$,1,20)$

What is the correct way to do this?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

The $ character denotes a token, usually a field, but never a function. @kmaron has a good suggestion.

---
If this reply helps you, Karma would be appreciated.
0 Karma

kmaron
Motivator

What about doing the substr in the actual search to create a new field and then using that result as the token?

woodcock
Esteemed Legend

I second this suggestion; you can make the new field invisible by naming it with a underscore ( _ ) as the first character.

Get Updates on the Splunk Community!

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...