-
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 }}%(wheredisplayis 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.

Thanks you I managed to find the soruce code and create my own custom alerts ✨
{{/* Plantilla Telegram */}} {{ define "alertas" -}} {{ range . }} {{ if len .Values -}} Values: {{- range $refID, $value := .Values -}} - {{ $refID }} = {{ $value }} {{ end -}} {{ end -}} {{ if len .Labels.SortedPairs }} Labels: {{ range .Labels.SortedPairs -}} - {{ .Name }} = {{ .Value }} {{ end -}} {{ end -}} {{ if len .Annotations.SortedPairs }} Annotations: {{ range .Annotations.SortedPairs -}} - {{ .Name }} = {{ .Value }} {{ end -}} {{ end -}} {{ end -}} {{/* range */}} {{ end -}} {{/* define alertas */}} {{ define "plantilla.message" }} {{ if gt (len .Alerts.Firing) 0 }} 🚨 FIRING!!! {{- template "alertas" .Alerts.Firing -}} {{ end -}} {{ if gt (len .Alerts.Resolved) 0 }} ✅ RESOLVED! {{- template "alertas" .Alerts.Resolved -}} {{ end -}} <a href="192.168.0.11:3000">Dashboard</a> {{ end }}