Referencing Variables
Overview
By referencing alert labels and attributes, you can customize incident severity and title information. This feature is mainly used in the following two scenarios:
- When reporting custom alert events using the Alert Event API, you can use the
title_rule
field to customize the alert title.
# Example: Specify resource and check labels as alert title
title_rule: "[TPL]${resource} / ${check}"
- In the alert pipeline, you can reference variables to modify incident severity, title, and description.

More Ways to Reference Variables
Generate Using ${var} Label References
Use [TPL] as prefix and ${} to reference variables. Variable content will be extracted from labels; if not found, replaced with <no value>.
Examples:
Rule | Label Values | Generated Content |
---|---|---|
[TPL]${resource} / ${check} | {"resource": "127.0.0.1", "check": "cpu idle low"} | 127.0.0.1 / cpu idle low |
[TPL]${resource} / ${check} | {"resource": "127.0.0.1"} | 127.0.0.1 / <no value> |
[TPL]${resource} / Host Down | {"resource": "127.0.0.1"} | 127.0.0.1 / Host Down |
Generate Using Golang Template Syntax
Use [TPL] as prefix and {{}} to reference variables (can reference labels and other variables). If not found, replaced with <no value>. Variable scope refers to Alert Event Definition.
Examples:
Rule | Label Values | Generated Content |
---|---|---|
[TPL]{{.Labels.resource}} / {{.Labels.check}} | {"resource": "127.0.0.1", "check": "cpu idle low"} | 127.0.0.1 / cpu idle low |
[TPL]{{.Labels.resource}} / {{.Labels.check}} | {"resource": "127.0.0.1"} | 127.0.0.1 / <no value> |
[TPL]{{.EventSeverity}} / Host Down | {"EventSeverity": "Warning"} | Warning / Host Down |
Supported Attribute List
Field | Type | Definition |
---|---|---|
Title | string | Title |
Description | string | Description |
EventSeverity | string | Event Severity |
FAQ
What happens if a label doesn't exist when using labels to generate titles?
It depends on which variable retrieval method you use. The title might retain the original variable information or use <no value> as a replacement.
Even if variables cannot be retrieved, it won't affect alert generation. You can debug with confidence.