Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pixelatedpic/0310551e91884cdccde09514c85511b4 to your computer and use it in GitHub Desktop.
Save pixelatedpic/0310551e91884cdccde09514c85511b4 to your computer and use it in GitHub Desktop.
How to fix Grafana Alerts to Telegram
  • Template name: telegram.message

  • Content:

    {{ define "alert_list" }}{{ range . }}{{ range .Annotations.SortedPairs }}<strong>{{ .Name }}</strong>: {{ .Value }}
    {{ end }}<strong>value</strong>: {{ or .ValueString "[no data]" }}
    {{ range .Labels.SortedPairs }}<strong>{{ .Name }}</strong>: {{ .Value }}
    {{ end }}| {{ if gt (len .GeneratorURL) 0 }}<a href="{{ .GeneratorURL }}">source</a> | {{ end }}{{ if gt (len .DashboardURL) 0 }}<a href="{{ .DashboardURL }}">dashboard</a> | {{ end }}{{ if gt (len .SilenceURL) 0 }}<a href="{{ .SilenceURL }}">silence</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" . }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment