Template reference
This documentation topic is designed for Grafana workspaces that support Grafana version 10.x.
For Grafana workspaces that support Grafana version 9.x, see Working in Grafana version 9.
For Grafana workspaces that support Grafana version 8.x, see Working in Grafana version 8.
This section provides reference information for creating your templates.
Alert (type)
The alert type contains the following data.
Name | Kind | Description | Example |
---|---|---|---|
Status |
string |
|
{{ .Status }} |
Labels |
KeyValue |
A set of labels attached to the alert. |
{{ .Labels }} |
Annotations |
KeyValue |
A set of annotations attached to the alert. |
{{ .Annotations }} |
Values | KeyValue | The values of all expressions, including Classic Conditions | {{ .Values }} |
StartsAt |
time.Time |
Time the alert started firing. |
{{ .StartsAt }} |
EndsAt |
time.Time |
Only set if the end time of an alert is known. Otherwise set to a configurable timeout period from the time since the last alert was received. |
{{ .EndsAt }} |
GeneratorURL |
string |
A back link to Grafana or external Alertmanager. |
{{ .GeneratorURL }} |
SilenceURL |
string |
A link to silence the alert (with labels for this alert pre-filled). Only for Grafana managed alerts. |
{{ .SilenceURL}} |
DashboardURL |
string |
Link to grafana dashboard, if alert rule belongs to one. Only for Grafana managed alerts. |
{{ .DashboardURL }} |
PanelURL |
string |
Link to grafana dashboard panel, if alert rule belongs to one. Only for Grafana managed alerts. |
{{ .PanelURL }} |
Fingerprint |
string |
Fingerprint that can be used to identify the alert. |
{{ .Fingerprint }} |
ValueString |
string |
A string that contains the labels and value of each reduced expression in the alert. |
{{ .ValueString }} |
ExtendedData
The ExtendedData object contains the following properties.
Name | Kind | Description | Example |
---|---|---|---|
Receiver |
|
The name of the contact point sending the notification. |
|
Status |
|
The status is |
|
Alerts |
|
List of all firing and resolved alerts in this notification. |
|
Firing alerts |
|
List of all firing alerts in this notification. |
|
Resolved alerts |
|
List of all resolved alerts in this notification. |
|
GroupLabels |
|
The labels that group these alerts int his notification. |
|
CommonLabels |
|
The labels common to all alerts in this notification. |
|
CommonAnnotations |
|
The annotations common to all alerts in this notification. |
|
ExternalURL |
|
A link to the Grafana workspace or Alertmanager that sent this notification. |
|
KeyValue type
The KeyValue
type is a set of key/value string pairs that represent
labels and annotations.
In addition to direct access of the data stored as a
KeyValue
, there are also methods for sorting, removing, and
transforming the data.
Name | Arguments | Returns | Notes | Example |
---|---|---|---|---|
SortedPairs |
Sorted list of key and value string pairs |
|
||
Remove |
[]string |
KeyValue |
Returns a copy of the Key/Value map without the given keys. |
|
Names |
[]string |
List of names |
|
|
Values |
[]string |
List of values |
|
Time
Time is from the Go time
Monday, 1st January 2022 at 10:00AM
,
you write the following template:
{{ .StartsAt.Format "Monday, 2 January 2006 at 3:04PM" }}
You can find a reference for Go’s time format here