Variables
Learn how to use variables and template functions in Dash0 check rules 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 triggering time series data.
When a check rule evaluates and detects an issue, you can reference specific label values from the time series and the actual metric value that caused the alert. Template functions then help format this data for better readability in notifications.
For example, the following configuration can be used to provide richer context to you and your colleagues within notifications:
The above configuration results in alerts like these:
Available Variables
Dash0 provides two primary variables for use in check rule templates:
$labels.{key}
references any label value from the time series that triggered the alert. Replace{key}
with the actual label name from your metrics. For example,$labels.service_name
retrieves the value of theservice_name
label, while$labels.k8s_pod_name
gets the pod name.$value
contains the numerical value that caused the check to fail. This represents the last evaluated metric value that exceeded your defined thresholds.
You can use these variables in both the summary and description fields of your check rules. They get replaced with actual values when the alert fires, providing specific context about what triggered the alert.
Template Functions for Numerical Values
When working with the $value
variable, Dash0 provides several formatting functions to make numerical data more human-readable:
humanize
converts large numbers into more readable formats using decimal-based units. For example,1000
becomes1k
, and1000000
becomes1M
. This function follows standard SI prefixes and is useful for general numerical data.humanize1024
applies binary-based formatting, commonly used for data sizes. It converts values like1024
to1Ki
and1048576
to1Mi
, following the IEC binary prefix standard typically used for bytes and memory measurements.humanizeDuration
transforms seconds into human-readable time formats. A value like3661
becomes1h 1m 1s
, making duration-based alerts much clearer for operators.humanizePercentage
formats decimal values as percentages. For instance,0.85
becomes85%
, which is particularly useful for utilization metrics and error rates.
Template Functions for String Values
For string manipulation of label values accessed through $labels.{key}
, Dash0 provides three formatting functions:
title
capitalizes the first letter of each word in the string. This is useful for making service names or resource identifiers more presentable in alert messages.toUpper
converts the entire string to uppercase, which can be helpful for emphasizing certain label values or maintaining consistency with naming conventions.toLower
converts the string to lowercase, useful for standardizing case-sensitive identifiers or ensuring consistent formatting across alerts.
Using Template Functions
Template functions wrap around variables using parentheses syntax. For numerical values, you apply functions to $value
:
CPU usage is {{ $value | humanizePercentage }} on service {{ $labels.service_name }}
Alert triggered for {{ $labels.deployment_environment_name | title }} environment in {{ $labels.cloud_region | toUpper }}
Memory usage has reached {{ $value | humanize1024 }}B on pod {{ $labels.k8s_pod_name }} in namespace {{ $labels.k8s_namespace }}
Last updated: June 1, 2025