Splunk Search

Variable reference in To: field of an email alert.

mdzmuran
Observer

Hi Splunk Team.

Can I use variable reference in To: field of an email alert? I have a distribution_list variable associated with my sourcetype and it is set to correct email address depending on date and time.  

U put $result.distribution_list$ in the To: field, but it does not send email.

Thanks

Michal

0 Karma

venkatasri
SplunkTrust
SplunkTrust

Hi @mdzmuran 

Yes you can use $result.distribution_list$ format in TO: field, however the search results should be having the value populated to distribution_list field, did you verify it?

How are you so sure email not been sent just checking the inbox ? Sometimes the Splunk user has been restricted to schedule alerts. Can you run following query to find out errors associated to your alert?

 

index=_internal source=*scheduler.log ERROR OR WARN

 

 To find send email errors,

 

index=_internal source=*python.log sendemail ERROR OR WARN

 

Hope mail server already configured in Splunk.

---

An upvote would be appreciated and Accept solution if this reply helps!

 

0 Karma

mdzmuran
Observer

HIi venkatasri.

The alerts are triggered, I can see them in Triggered alerts.

If I replace $result.distribution_list$ with regular email address, the emails are sent.

The queries suggested do not return any data. It may be due to access permissions, I asked administrators to run them.

One more info, it may be important. The distribution_list variable is not defined in the search query. It is defined in the Calculated Fields setting for this particular sourcetype. I can see it, however, in the search results if I run the alert query manually.picture.jpg

Michal

0 Karma

venkatasri
SplunkTrust
SplunkTrust

@mdzmuran 

As per docs the field shall be explicitly available in results.  Try including distribution_list to results using | fields command. Hope this helps!

$result.fieldname$First value for the specified field name from the first search result row. Verify that the search generates the field being accessed.
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 ...