Use tokens in email notifications
Tokens represent data that a search generates. They work as placeholders or variables for data values that populate when the search completes.
You can use tokens in the following fields of an email notification.
- To
- Cc
- Bcc
- Subject
- Message
- Footer
If you have Splunk Enterprise, you can change footer text by editing alert_actions.conf
.
Use this token syntax to reference values from the search: $<token>$
For example, place the following text and token in the subject field of an email notification to reference the search ID of a search job:
Search results from $job.sid$
Tokens available for email notification
There are four categories of tokens that access data generated by searches. Token availability varies by context.
Category | Context: Alert Actions | Context: Scheduled Reports | Context: Scheduled PDF delivery |
---|---|---|---|
Search metadata | Yes | Yes | Yes |
Search results | Yes | Yes | No |
Job information | Yes | Yes | No |
Server information | Yes | Yes | Yes |
Dashboard information | No | No | Yes |
If you have Splunk Enterprise, you can use tokens to access values for attributes listed in savedsearches.conf
and alert_actions.conf
. Use the attribute name with standard token syntax. For example, to access an email notification subject, use
$action.email.subject$
.
Search metadata tokens
Common tokens that access information about a search.
Token | Description |
---|---|
$action.email.hostname$ | Email server hostname |
$action.email.priority$ | Search priority |
$alert.expires$ | Alert expiration time |
$alert.severity$ | Alert severity level |
$app$ | App context for the search |
$cron_schedule$ | Search cron schedule |
$description$ | Human-readable search description |
$name$ | Search name |
$next_scheduled_time$ | The next time the search runs |
$owner$ | Search owner |
$results_link$ | (Alert actions and scheduled reports only) Link to search results |
$search$ | Search string |
$trigger_date$ | (Alert actions only) Date when alert triggered, formatted as Month(string) Day, Year
|
$trigger_time$ | (Alert actions only) Time when alert triggered, formatted as epoch time |
$type$ | Indicates if the search is from an alert, report, view, or the search command |
$view_link$ | Link to view saved search |
Result tokens
You can access field values from the first result row that a search returns. Field availability for tokens depends on what fields are available in search results.
Token | Description |
---|---|
$result.fieldname$ | First value for the specified field name from the first search result row. Verify that the search generates the field being accessed. |
To include or exclude specific fields from the results, use the fields
command in the base search for the alert. For more information, see fields in the Search Reference.
Job information tokens
Common tokens that access data specific to a search job, such as the search ID or messages generated by the search job.
Token | Description |
---|---|
$job.earliestTime$ | Initial job start time |
$job.eventSearch$ | Subset of the search that appears before any transforming commands |
$job.latestTime$ | Latest time recorded for the search job |
$job.messages$ | List of error and debug messages generated by the search job |
$job.resultCount$ | Search job result count |
$job.runDuration$ | Time, in seconds, for search job completion |
$job.sid$ | Search ID |
$job.label$ | Search job name |
Server tokens
Provide details about your Splunk deployment.
Token | Description |
---|---|
$server.build$ | Build number of the Splunk deployment. |
$server.serverName$ | Server name hosting the Splunk deployment. |
$server.version$ | Version number of the Splunk deployment. |
Dashboard metadata tokens
Access dashboard metadata and include it in dashboard delivery emails.
Token | Description |
---|---|
$dashboard.label$ | Dashboard label |
$dashboard.title$ | Equivalent to $dashboard.label$
|
$dashboard.description$ | Dashboard description |
$dashboard.id$ | Dashboard ID |
Deprecated email notification tokens
The following tokens are deprecated.
Token | Alternative option |
---|---|
$results.count$ | (Deprecated) Use $job.resultCount$. |
$results.file$ | (Deprecated) No equivalent available. |
$results.url$ | (Deprecated) Use $results_link$. |
$search_id$ | (Deprecated) Use $job.sid$. |
Email notification action | Use a webhook alert action |
This documentation applies to the following versions of Splunk® Enterprise: 7.0.0, 7.0.1, 7.0.2, 7.0.3, 7.0.4, 7.0.5, 7.0.6, 7.0.7, 7.0.8, 7.0.9, 7.0.10, 7.0.11, 7.0.13, 7.1.0, 7.1.1, 7.1.2, 7.1.3, 7.1.4, 7.1.5, 7.1.6, 7.1.7, 7.1.8, 7.1.9, 7.1.10, 7.2.0, 7.2.1, 7.2.2, 7.2.3, 7.2.4, 7.2.5, 7.2.6, 7.2.7, 7.2.8, 7.2.9, 7.2.10, 7.3.0, 7.3.1, 7.3.2, 7.3.3, 7.3.4, 7.3.5, 7.3.6, 7.3.7, 7.3.8, 7.3.9, 8.0.0, 8.0.1, 8.0.2, 8.0.3, 8.0.4, 8.0.5, 8.0.7, 8.0.10, 8.1.0, 8.1.1, 8.1.2, 8.1.3, 8.1.4, 8.1.5, 8.1.6, 8.1.7, 8.1.8, 8.1.9, 8.1.10, 8.1.11, 8.1.12, 8.1.13, 8.1.14, 8.2.0, 8.2.1, 8.2.2, 8.2.3, 8.2.4, 8.2.5, 8.2.6, 8.2.7, 8.2.8, 8.2.9, 8.2.10, 8.2.11, 8.2.12, 9.0.0, 9.0.1, 9.0.2, 9.0.3, 9.0.4, 9.0.5, 9.0.6, 9.0.7, 9.0.8, 9.0.9, 9.0.10, 9.1.0, 9.1.1, 9.1.2, 9.1.3, 9.1.4, 9.1.5, 9.1.6, 8.0.6, 8.0.8, 8.0.9
Feedback submitted, thanks!