Basic Template
- Go to Alerting → Contact points and click Add notification template group
- Give the template a name and paste the body template (below) into the Alert content area
- Click Save
Body
{{ define "metrics_template" }}
{{ if and .CommonLabels.alertname (ne .CommonLabels.alertname "") -}}
*Alert:* {{ .CommonLabels.alertname }}
{{ end }}
*Status:* {{ if eq .Status "firing" }}🚨 *Firing* 🚨{{ else if eq .Status "resolved" }}✅ *Resolved* ✅{{ else }}ℹ️ *{{ .Status | title }}* ℹ️{{ end }}
{{ if and .CommonLabels.instance (ne .CommonLabels.instance "") -}}
*Instance:* {{ .CommonLabels.instance }}
{{ end }}
{{- if .CommonAnnotations.panel_url -}}
*Panel Link:* <{{ .CommonAnnotations.panel_url }}|Click here>
{{ end }}
{{ if and .CommonAnnotations.summary (ne .CommonAnnotations.summary "") -}}
*Summary:* {{ .CommonAnnotations.summary }}
{{ end }}
{{ if and .CommonAnnotations.description (ne .CommonAnnotations.description "") -}}
*Description:* {{ .CommonAnnotations.description }}
{{ end }}
{{ end }}
Slack Contact Point
Create Webhook
- Go to: Slack APIs
- Click the Create App button and choose the
From scratch
option
- You’ll be redirected to your new app’s Basic Information page
- Click Incoming Webhooks in the left-hand navigation
- Scroll down and click Add New Webhook
- Select the channel you want alerts sent to
- Click Allow
- Copy the webhook URL now showing at the bottom of the page
Create Contact Point
- In Grafana, go to Alerting → Contact points