Getting Alerts in slack from Grafana. But it's not in a good format. Is there any way to customize the notification in slack from Grafana?. I am using Node exporter to export the metrics. The dashboard is downloaded from https://grafana.com/grafana/dashboards/1860
How to customize the notification like:
Heading: ALERT CPU LOAD ON SERVER
Instance IP: 192.x.x.x.x Value: 90% of CPU used Priority: High
Sample output in slack is attached.

So i managed to work it out nicely according to my needs with the help of this guide :
https://community.grafana.com/t/how-to-use-alert-message-templates-in-grafana/67537/3
I will never the less post the config here as well:
{{ define "myalert" }}
[{{.Status}}] {{ .Labels.alertname }}
{{ .Annotations.AlertValues }}
{{ end }}
{{ define "mymessage" }}
{{ if gt (len .Alerts.Firing) 0 }}
{{ len .Alerts.Firing }} firing:
{{ range .Alerts.Firing }} {{ template "myalert" .}} {{ end }}
{{ end }}
{{ if gt (len .Alerts.Resolved) 0 }}
{{ len .Alerts.Resolved }} resolved:
{{ range .Alerts.Resolved }} {{ template "myalert" .}} {{ end }}
{{ end }}
{{ end }}
Alert summary:
{{ template "mymessage" . }}
Alert summary:
{{ with $values }}
{{ range $k, $v := . }}
Location: {{$v.Labels.device}}
Variable: {{$v.Labels.instance}}
Alerting value: {{ $v }}
{{ end }}
{{ end }}
^^ device and instance may vary, based on query returned values(labels)
And the result i get:
Alert summary:
1 firing:
[firing] EKS Storage
Location: /dev/nvme0n1p1
Variable: 10.0.112.170:9100
Alerting value: 24.88013967279807
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With