Skip to content

Sample Notification Templates

This section provides ready-to-use examples of notification templates to help you quickly format alert messages.

LabelDescription
alert_codeCustom code representing the alert for easy tracking.
alertnameFull name or title describing the alert situation.
datasetDataset is a collection of data within the data source associated with the alert.
tableTable name related to the dataset triggering the alert.
severitySeverity level of the alert (e.g., critical, warning).
descriptionProvides a brief, high-level overview of the alert rule for quick identification.
summaryOffers detailed context and explanation of the alert, helping users understand its cause and impact.

Notification Template Examples — Code Snippets and Email Previews

Section titled “Notification Template Examples — Code Snippets and Email Previews”

Example snippet for the email body:

{{ define "Notification-email" -}}
{{ range .Alerts -}}
{{- $alertCode := index .Labels "alert_code" -}}
{{- $alertName := index .Labels "alertname" -}}
{{- $dataset := index .Labels "dataset" -}}
{{- $summary := index .Annotations "summary" -}}
{{- $table := index .Labels "table" -}}
{{- $severity := index .Labels "severity" -}}
{{- $name := index .Labels "alertName" -}}
{{- $description := index .Annotations "description" -}}
{{- if and $alertCode $alertName $description $severity -}}
{{- if not (or (match "DatasourceNoData" $alertName) (match "DatasourceError" $alertName)) }}
{{- if eq $severity "critical" }}
🚨 {{ title $severity }} Alert: {{ $alertName }}
{{- else if eq $severity "warning" }}
⚠️ {{ title $severity }} Alert: {{ $alertName }}
{{- end }}
{{- if and $dataset (ne $dataset "all") }}
📦 Dataset: "{{ $dataset }}"
{{- end }}
{{- if $table }}
📊 Table: "{{ $table }}"
{{- end }}
📛 Alert Code: {{ $alertCode }}
📌 Impact Summary: {{ $summary }}
🔗 For more assistance reach out to administrative support or refer https://docs.obsrv.ai/how-tos/alerts-and-notifications/alerts-and-recommended-actions
{{- end }}
{{- end -}}
{{ end -}}
{{ end }}

Below is an example of how the email notification looks when triggered:

Email notification example showing critical alert with dataset, alert code and impact summary


Example snippet for the email body:

{{ define "Simple-Notification-Template" -}}
{{ range .Alerts -}}
📛 Alert Code: {{ index .Labels "alert_code" }}
🏷️ Alert Name: {{ index .Labels "alertname" }}
⚠️ Severity: {{ index .Labels "severity" }}
📝 Summary: {{ index .Annotations "description" }}
🖥️ Alert Source: {{ index .Labels "alertSource" }}
📊 Dataset: {{ index .Labels "dataset" }}
🔗 For more assistance reach out to administrative support or refer https://obsrv.sunbird.org/
{{ end -}}
{{ end }}

Below is an example of how the email notification looks when triggered:

Simple email notification example showing alert name, severity and summary fields