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

    Annotations and labels for alerting rules - 图2

    Template variables

    Template functions

    The following template functions are available when expanding annotations and labels.

    NameArgumentReturnDescription
    humanizenumber or stringstringConverts a number to a more readable format, using metric prefixes.
    humanize1024number or stringstringLike humanize, but uses 1024 as the base rather than 1000.
    humanizeDurationnumber or stringstringConverts a duration in seconds to a more readable format.
    humanizePercentagenumber or stringstringConverts a ratio value to a fraction of 100.
    humanizeTimestampnumber or stringstringConverts a Unix timestamp in seconds to a more readable format.
    titlestringstringstrings.Title, capitalises first character of each word.
    toUpperstringstringstrings.ToUpper, converts all characters to upper case.
    toLowerstringstringstrings.ToLower, converts all characters to lower case.
    matchpattern, textbooleanregexp.MatchString Tests for a unanchored regexp match.
    reReplaceAllpattern, replacement, textstringRegexp.ReplaceAllString Regexp substitution, unanchored.
    graphLinkexprstringNot supported
    tableLinkexprstringNot 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.
    externalURLnothingstringReturns a string representing the external URL.
    pathPrefixnothingstringReturns the path of the external URL.
    tmplstring, []interface{}nothingNot supported
    safeHtmlstringstringNot supported
    queryquery string[]sampleNot supported
    first[]samplesampleNot supported
    labellabel, samplestringNot supported
    strvalue[]samplestringNot supported
    valuesamplefloat64Not supported
    sortByLabellabel, []samples[]sampleNot supported