- Template name:
telegram.message
- Content:
{{- /* Telegram message to use: {{ template "telegram.message2" . }} */ -}}
{{ define "__alerts_list" -}}
{{ range . }}
{{if ne (index .Labels "alertname") "" -}}
{{ if eq .Status "firing" }}π΄{{ else }}π’{{ end }}
{{- if ne (index .Labels "severity") "" -}}
<u><b>P{{ index .Labels "severity" }}</b></u> {{ end -}}
<b>{{ index .Labels "alertname" }}</b> π {{ .StartsAt.Format "15:04:05 ποΈ 2006-01-02" }}{{ end -}}
{{ if len .Annotations }}
<i>Annotations:</i>
{{ range .Annotations.SortedPairs -}}
- {{ .Name }}: {{ .Value }}
{{ end -}}
{{ end }}
{{ if len .Labels -}}
<i>Labels:</i>
{{ range .Labels.SortedPairs -}}
- {{ .Name }}: {{ .Value }}
{{ end -}}
{{ end }}
<i>Value:</i> <pre>{{ .ValueString }}</pre>
{{- 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 -}}
<pre>--------</pre>
{{- end -}} {{- /* range */ -}}
{{- end -}} {{- /* define __alerts_list */ -}}
{{ define "__telegram.title" -}}
{{ if ne (index .CommonLabels "severity") "" }} <u><b>P{{ index .CommonLabels "severity" }}</b></u> {{ end -}}
{{ if ne (index .CommonLabels "alertname") "" -}}
[{{ index .CommonLabels "alertname" }}]
{{- end -}}
{{- end -}}{{- /* define __telegram */ -}}
{{ define "telegram.message" }}
{{ if gt (len .Alerts.Firing) 0 }}
π¨ <b>ALARM</b> (#{{ .Alerts.Firing | len }})
{{- template "__alerts_list" .Alerts.Firing }}{{ end -}}
{{ if gt (len .Alerts.Resolved) 0 }}
β
<b>RESOLVED</b>{{ template "__telegram.title" . }} (#{{ .Alerts.Resolved | len }})
{{- template "__alerts_list" .Alerts.Resolved }}{{ end }}
<a href="{{ .ExternalURL }}">π² Grafana</a>
{{- 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 }}%` (where `display` is one of the queries).
- I usually add the following queries: `data` (the datasource query), `metric` (the reduce expression), `condition`, and `display`, which is `round($metric)`. [Multi-dimensional rules documentation](https://grafana.com/docs/grafana/next/alerting/alerting-rules/create-grafana-managed-rule).
Hello @gelldur
Is it possible to include the server in value parameter of solved? The empty value will make ambiguity to identify which system have been solved.
Another question is, is it possible to change summary of solved? For now in both cases (firing and solved) it uses the same summary.