Skip to content

Instantly share code, notes, and snippets.

@orlovmyk
Last active September 8, 2024 15:19
Show Gist options
  • Save orlovmyk/1a6d04bcb2d64a65da9843986af89d48 to your computer and use it in GitHub Desktop.
Save orlovmyk/1a6d04bcb2d64a65da9843986af89d48 to your computer and use it in GitHub Desktop.
alertmanager template for Telegram message
{{ define "__alert_list" }}{{ range . }}
{{/* Severity of the alert */}}
{{- if eq .Labels.severity "critical" -}}
❗️
{{- else if eq .Labels.severity "warning" -}}
⚠️
{{- else if eq .Labels.severity "info" -}}
ℹ️
{{- else -}}
❓{{/* uncomment if you want to know .Labels.severity */}}
{{- end -}}
<b>{{ .Labels.alertname }}</b>
{{- if .Annotations.summary }}
📝 {{ .Annotations.summary }}
{{- end -}}
{{- if .Annotations.description }}
💬 {{ .Annotations.description }}
{{- end -}}
{{- if .Labels.alertname }}
<a href="https://alertmanager.example.ua">💊 Alertmanager</a>
{{- end -}}
{{- if .Annotations.runbook_url -}}
<a href="{{ .Annotations.runbook_url }}">📗 Runbook</a>
{{- end -}}
{{ end }}
{{ end }}
{{/* The text to display in the alert */}}
{{ define "telegram.message" }}
{{- if gt (len .Alerts.Firing) 0 -}}
<b><i>🔥 Firing:{{- len .Alerts.Firing -}} 🔥</i></b>
{{- template "__alert_list" .Alerts.Firing -}}
{{- end -}}
{{- if gt (len .Alerts.Resolved) 0 -}}
<b><i>✅ Resolved:{{- len .Alerts.Resolved -}} ✅</i></b>
{{- template "__alert_list" .Alerts.Resolved -}}
{{- end -}}
{{ end }}
@orlovmyk
Copy link
Author

orlovmyk commented Sep 8, 2024

image

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