Last updated: May 30, 2026
Optimize Alert Messages with Templates
Reference guide for variables and template functions in Dash0 check rules. Use these to create dynamic, contextual alert messages with automatic formatting for better incident response.
Overview
Dash0's check rules support dynamic content through variables and template functions in the summary and description fields. This templating system, compatible with Prometheus conventions, allows you to create contextual alert messages that automatically include relevant information from the failing check.
When a check rule detects an issue, you can reference specific label values and the actual metric value that caused the alert. Template functions then help format this data for better readability in notifications.
Reference Available Variables
Use these variables to dynamically include metric values and label data in your alert messages. Dash0 provides three primary variables for use in check rule templates:
$thresholdcontains the threshold value that was exceeded (either degraded or critical, whichever fired). This is the value you configured in the Thresholds section of the check rule.$valuecontains the actual numerical value that caused the check to fail. This represents the last evaluated metric value that exceeded your defined threshold.$labels.<key>references any label value associated with the alert. Replace<key>with the actual label name. For example,$labels.service_nameretrieves the service name, while$labels.k8s_pod_namegets the pod name.
Where labels come from:
Labels available in $labels come from two sources:
- Query results: Labels projected by your PromQL query (visible in the evaluation preview chart)
- Check rule labels: Custom labels added to the check rule in the Additional Labels section
You can use these variables in both the summary and description fields of your check rules. They are replaced with actual values when the alert fires, providing specific context about what triggered it.
Format Values with Template Functions
Dash0's templating system is compatible with Prometheus Alertmanager template functions, providing numerical and string formatting capabilities. The following functions can be used to format values in alert messages:
Numerical Formatting
humanizeconverts large numbers into readable formats using decimal-based units. For example,1000becomes1k, and1000000becomes1M.humanize1024applies binary-based formatting, commonly used for data sizes. It converts values like1024to1Kiand1048576to1Mi, following IEC binary prefix standards.humanizeDurationtransforms seconds into human-readable time formats. A value of3661becomes1h 1m 1s.humanizePercentageformats decimal values as percentages. For instance,0.85becomes85%.
String Formatting
titlecapitalizes the first letter of each word in the string.toUpperconverts the entire string to uppercase.toLowerconverts the string to lowercase.
Template function autocomplete is not available in the UI editor, but the functions are supported when alerts are sent. Refer to the Prometheus Alertmanager template reference for the complete list of available functions.
Apply Template Functions
Combine variables with template functions using the pipe operator to format values for better readability in notifications. Template functions wrap variables using the {{ }} syntax:
1CPU usage is {{ $value | humanizePercentage }} on service {{ $labels.<service_name> }}
1Alert triggered for {{ $labels.<deployment_environment_name> | title }} environment in {{ $labels.<cloud_region> | toUpper }}
1Memory usage has reached {{ $value | humanize1024 }}B on pod {{ $labels.<k8s_pod_name> }} in namespace {{ $labels.<k8s_namespace> }}
Further Reading
- About Alert Monitoring — Overview of Dash0's alerting capabilities and how check rules monitor your systems.
- Create Check Rules — Set up check rules to monitor metrics, logs, spans, and web events using PromQL expressions and threshold values.
- Send Check Rule Notifications — Configure notification channels to keep your team informed when checks fail.
- How the Alerting Model Works — Reference guide for Dash0's extension of the Prometheus alerting model with degraded and critical severity thresholds.