Last active
September 8, 2024 15:19
-
-
Save orlovmyk/1a6d04bcb2d64a65da9843986af89d48 to your computer and use it in GitHub Desktop.
alertmanager template for Telegram message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ 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 }} |
Author
orlovmyk
commented
Sep 8, 2024

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