Annotations and labels for alerting rules
Annotations are key-value pairs that provide additional meta-information about an alert. For example: a description, a summary, and runbook URL. These are displayed in rule and alert details in the UI and can be used in contact type message templates. Annotations can also be templated, for example will have the evaluated instance
label value added for every alert this rule produces.
Labels
Template variables
Template functions
The following template functions are available when expanding annotations and labels.
Name | Argument | Return | Description |
---|---|---|---|
humanize | number or string | string | Converts a number to a more readable format, using metric prefixes. |
humanize1024 | number or string | string | Like humanize, but uses 1024 as the base rather than 1000. |
humanizeDuration | number or string | string | Converts a duration in seconds to a more readable format. |
humanizePercentage | number or string | string | Converts a ratio value to a fraction of 100. |
humanizeTimestamp | number or string | string | Converts a Unix timestamp in seconds to a more readable format. |
title | string | string | strings.Title, capitalises first character of each word. |
toUpper | string | string | strings.ToUpper, converts all characters to upper case. |
toLower | string | string | strings.ToLower, converts all characters to lower case. |
match | pattern, text | boolean | regexp.MatchString Tests for a unanchored regexp match. |
reReplaceAll | pattern, replacement, text | string | Regexp.ReplaceAllString Regexp substitution, unanchored. |
graphLink | expr | string | Not supported |
tableLink | expr | string | Not supported |
args | []interface{} | map[string]interface{} | Converts a list of objects to a map with keys, for example, arg0, arg1. Use this function to pass multiple arguments to templates. |
externalURL | nothing | string | Returns a string representing the external URL. |
pathPrefix | nothing | string | Returns the path of the external URL. |
tmpl | string, []interface{} | nothing | Not supported |
safeHtml | string | string | Not supported |
query | query string | []sample | Not supported |
first | []sample | sample | Not supported |
label | label, sample | string | Not supported |
strvalue | []sample | string | Not supported |
value | sample | float64 | Not supported |
sortByLabel | label, []samples | []sample | Not supported |