Alerting

How to make fields show in an alert?

unitedmarsupial
Path Finder

I have an alert based on the below search (obfuscated):

 

...
| eval APPDIR=source
| rex field=APPDIR mode=sed "s|/logs\/.*||g"
| eventstats values(APPDIR) as APPDIRS
| eval Level=if("/app/5000" IN (APPDIRS), "PRODUCTION", "Non-production")
| eval APPDIRS=mvjoin(APPDIRS, ",")

 

The idea is to discern the affected application-instance (there are multiple logs under each of the /app/instance/logs/) and then to determine, whether the instance is a production one or not. In the search-results all three new fields (APPDIR, APPDIRS, and Level) are populated as expected.

But they don't show up in the e-mails. The "Subject: $Level$ app in $APPDIRS$" expands to mere "Subject:  app in ". Nor are the fields expanded in the body of the alert e-mail.

Now, I understand, that event-specific fields -- like the singular APPDIR above -- cannot be expected to work in an alert. But the plural APPDIRS, as well as the Level, are aggregates, aren't they?

What am I doing wrong, and how do I fix it?

Labels (2)
Tags (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Have you tried "Subject: $result.Level$ app in $result.APPDIRS$"?

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

unitedmarsupial
Path Finder

Oh, I see... But should not it be $result.Level$ -- that is, singular "result", not plural "results"? Thanks!

richgalloway
SplunkTrust
SplunkTrust

You are correct.  Use the singular form.

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

unitedmarsupial
Path Finder

If you edit your earlier answer to correct the syntax, I'll be able to mark it as the solution...

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Done

---
If this reply helps you, Karma would be appreciated.
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!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...