-
Template name:
telegram.message
-
Content:
{{ define "alert_list" }}{{ range . }}{{ .Labels.alertname }} {{ range .Annotations.SortedPairs }}<strong>{{ .Name }}</strong>: {{ .Value }} {{ end }}| {{ if gt (len .GeneratorURL) 0 }}<a href="{{ .GeneratorURL }}">source</a> | {{ end }}{{ if gt (len .SilenceURL) 0 }}<a href="{{ .SilenceURL }}">silence</a> | {{ end }}{{ if gt (len .DashboardURL) 0 }}<a href="{{ .DashboardURL }}">dashboard</a> | {{ end }}{{ if gt (len .PanelURL) 0 }}<a href="{{ .PanelURL }}">panel</a> |{{ end }} — {{ end }}{{ end }} {{ define "telegram.message" }} {{ if gt (len .Alerts.Firing) 0 }}<strong>FIRING!!!</strong> — {{ template "alert_list" .Alerts.Firing }} {{ if gt (len .Alerts.Resolved) 0 }} {{ end }}{{ end }}{{ if gt (len .Alerts.Resolved) 0 }}<strong>Resolved</strong> — {{ template "alert_list" .Alerts.Resolved }} {{ end }}{{ end }}
-
Contact point | Optional Telegram settings | Message:
{{ template "telegram.message" . }}
-
Add verbose annotations to your alerts. Example:
The <code>{{ $labels.host }}</code> host is low on free space! Used: {{ $values.display.Value }}%
(wheredisplay
is one of the queries). -
I usually add the following queries:
data
(the datasource query),metric
(the reduce expression),condition
, anddisplay
, which isround($metric)
. Multi-dimensional rules documentation.
Also, check out this fork by @gelldur, this templeate is much more cmprehensive.
https://grafana.com/docs/grafana/latest/alerting/images-in-notifications/ - I am using telegram so looks like, there is no option currently for it.
Regarding values from "Expression". Is it possible to loop over values, with dynamic metric's and variable? Eg. B0, B1, as in below example?
Value: [ var='B0' metric='test1' labels={} value=0.8555555555555555 ], [ var='B1' metric='test2' labels={} value=0.8740740740740741 ]
Labels: