Function | Description |
Go Template built-in functions | Notification templates support Go Template built-in functions such as range, if, with, and len. For details, see the official documentation. |
translate(typ, lang, val) | Convert values such as Type and Region into natural language. Example: {{ translate "Type" "zh" .Type }}. |
levelColor(level, isRecovered) | Return the channel color value based on the severity level and whether the alert has recovered. Example: {{ levelColor .Level false }}. |
levelCss(level, isRecovered) | Return a CSS class based on the severity level and whether the alert has recovered. Example: {{ levelCss .Level false }}. |
formatKeyValues(kvs) | Format []KeyValues into k={v1,v2} text. Example: {{ formatKeyValues .Labels }}. |
getMetrics(typ, metrics) | Filter the metric list by alert type for better display. Example: {{ range $m := getMetrics .Type $resource.Metrics }}. |
Time formatting | Fields of the time.Time type supports .Format. Example: {{ .HappenedAt.Format "2006-01-02 15:04:05" }}. |