Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.chronosphere.io/llms.txt

Use this file to discover all available pages before exploring further.

This feature isn’t available to all Chronosphere Observability Platform users and might not be visible in your app. For information about enabling this feature in your environment, contact Chronosphere Support.
Use notification templates to control the title and description of notifications generated by a monitor. Templates are Go template strings expanded at notification time with alert context, so the notification can include signal data such as severity, labels, and threshold values. A notification template has two optional fields:
  • Title: The subject line or heading of the notification.
  • Description: The body text of the notification.
To add a notification template to a monitor, see Create a monitor or Edit a monitor. For the notification_template field definition, see the monitor data model.

Set a notification template

Add a notification_template block when creating or updating a monitor.
Include a notification_template block in your monitor YAML when running chronoctl monitors create or chronoctl monitors update. For more information, see Chronoctl.
notification_template:
  title: "[{{.Severity}}] {{.Labels.service}} — error rate alert"
  description: >-
    Service {{.Labels.service}} in {{.Labels.env}} fired
    {{.ThresholdOp}} {{.Threshold}}. Status: {{.Status}}.

Error rate alert example

The following template uses severity and label variables to produce a notification title and description.
{
  "title": "[{{.Severity}}] {{.Labels.service}} threshold exceeded",
  "description": "{{.Labels.env}} crossed {{.ThresholdOp}} {{.Threshold}}"
}
For a critical alert on the payments service in production, Chronosphere Observability Platform renders the notification as:
[critical] payments threshold exceeded
production crossed >= 0.95

Template variables

Reference variables with dot notation, for example, {{.Severity}}.
VariableTypeDescription
.SeveritystringAlert severity: "critical" or "warn".
.StatusstringAlert state: "firing" or "resolved".
.Labels.<name>stringSignal labels attached to the alert. For example, .Labels.env or .Labels.service.
.ThresholdnumberThreshold value for the active severity condition.
.ThresholdOpstringComparison operator for the active condition. For example, ">=" or "<".
.ResolveThresholdnumberEffective resolve threshold. Defaults to .Threshold when no separate resolve threshold is configured.
.StartsAtEpochintegerStart time of the earliest alert in .Alerts, in epoch milliseconds.
.AlertslistAll alerts in the notification group. See Alert object fields.
.Alerts.FiringlistSubset of .Alerts that are currently firing.
.Alerts.ResolvedlistSubset of .Alerts that have resolved.

Alert object fields

Each item in .Alerts, .Alerts.Firing, and .Alerts.Resolved exposes the following fields:
FieldTypeDescription
.StatusstringAlert state: "firing" or "resolved".
.LabelsmapPer-alert label key/value pairs.
.AnnotationsmapPer-alert annotation key/value pairs.
.ThresholdnumberPer-alert threshold value.
.ThresholdOpstringPer-alert comparison operator.
.ResolveThresholdnumberPer-alert effective resolve threshold.
.StartsAttimestampTime the alert started firing.
.EndsAttimestampTime the alert resolved, if applicable.

Template functions

In addition to the standard Go template built-ins, the following functions are available.

Arithmetic

FunctionDescriptionExample
addAdds two integers.{{add 1 2}} returns 3
subSubtracts two integers.{{sub 5 3}} returns 2
mulMultiplies two integers.{{mul 3 4}} returns 12

String manipulation

FunctionDescriptionExample
toUpperConverts a string to uppercase.{{toUpper .Labels.env}} returns PRODUCTION
toLowerConverts a string to lowercase.{{toLower .Labels.env}} returns production
titleTitle-cases a string.{{title .Labels.env}} returns Production
joinJoins a string slice with a separator.{{join .Labels.regions ", "}}
matchReturns true if a string matches a regular expression.{{match "^prod" .Labels.env}}
reReplaceAllReplaces all regexp matches in a string.{{reReplaceAll "-" "_" .Labels.service}}

Template examples

Count firing and resolved alerts

{{len .Alerts.Firing}} firing, {{len .Alerts.Resolved}} resolved

List all firing alerts

{{range .Alerts.Firing -}}
- {{.Labels.service}} ({{.Labels.env}})
{{end}}

Show the resolve threshold conditionally

Threshold: {{.ThresholdOp}} {{.Threshold}}
{{- if ne .ResolveThreshold .Threshold}} (resolves at {{.ResolveThreshold}}){{end}}

Reference the alert start time

Alert started at epoch ms: {{.StartsAtEpoch}}