Reporting

Splunk Scheduled PDF - Use token on mail subject

nuaraujo
Path Finder

Hello everyone

I have a scheduled PDF delivery mail, where I want to manipulate the mail subject, using a mail token. Basically, I want to add the word SUCCESS or ERROR, to the mail subject.

To achieve this, on my dashboard, I am using a global search, where I am creating a token, using the following code:

<search id="get_status_token">
    <query>my_search_here
| eval fstatus=if(AAA==BBB AND CCC==DDD  , "SUCCESS","ERROR")
| fields fstatus</query>
    <earliest>-1d@d</earliest>
    <latest>@d</latest>
    <sampleRatio>1</sampleRatio>
    <done>
      <set token="fstatus">$result.fstatus$</set>
    </done>
  </search>

On the EDIT PDF SCHEDULE menu, I adding the following code as Subject

TEST $fstatus$

but the email does never display the value of the token in the subject.

Can someone help me find what am I missing?

NOTE: I am using the token in the email subject and not in the PDF.

Thanks in advance

Tags (1)
0 Karma
1 Solution

masonmorales
Influencer

Instead of setting a token in the XML of the report, try using a token with the sendemail command.
i.e.

<query>my_search_here
 | eval fstatus=if(AAA==BBB AND CCC==DDD  , "SUCCESS","ERROR")
 | fields fstatus
 | sendemail to=someone@somewhere.net sendpdf=t subject=$result.fstatus$</query> 

View solution in original post

0 Karma

masonmorales
Influencer

Instead of setting a token in the XML of the report, try using a token with the sendemail command.
i.e.

<query>my_search_here
 | eval fstatus=if(AAA==BBB AND CCC==DDD  , "SUCCESS","ERROR")
 | fields fstatus
 | sendemail to=someone@somewhere.net sendpdf=t subject=$result.fstatus$</query> 
0 Karma

nuaraujo
Path Finder

Thanks @masonmorales for the quick reply, but since in this dashboard I have 3 different searches, this would require at least 3 mails.

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!

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas

Why Splunk Customers Should Attend Cisco Live 2026 Las Vegas     Cisco Live 2026 is almost here, and this ...

What Is the Name of the USB Key Inserted by Bob Smith? (BOTS Hint, Not the Answer)

Hello Splunkers,   So you searched, “what is the name of the usb key inserted by bob smith?”  Not gonna lie… ...

Automating Threat Operations and Threat Hunting with Recorded Future

    Automating Threat Operations and Threat Hunting with Recorded Future June 29, 2026 | Register   Is your ...