Files
homelab/prometheus-stack/k8s/alertmanager-telegram.tmpl
forust 5936de3e56 fix(alertmanager): quote null receiver and wire telegram template
Unquoted null parses as YAML null and breaks routing. Add shared telegram message template.
2026-09-18 19:02:41 +02:00

44 lines
1.4 KiB
Cheetah
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{- define "telegram.forust.message" -}}
{{- $statusEmoji := "🚨" -}}
{{- if ne .Status "firing" -}}{{- $statusEmoji = "✅" -}}{{- end -}}
{{- $count := len .Alerts.Firing -}}
{{- if eq .Status "resolved" -}}{{- $count = len .Alerts.Resolved -}}{{- end -}}
{{ $statusEmoji }} <b>{{ .Status | toUpper }} ({{ $count }})</b>
{{- range .Alerts }}
<b>{{ .Labels.alertname }}</b>
{{- $sev := .Labels.severity }}
{{- if eq $sev "critical" }} 🔥 critical
{{- else if eq $sev "warning" }} ⚠️ warning
{{- else if eq $sev "info" }} ℹ️ info
{{- else if $sev }} • {{ $sev }}
{{- end }}
{{- if .Annotations.description }}
<i>{{ .Annotations.description }}</i>
{{- end }}
{{- if .Labels.namespace }}
📦 Namespace: <code>{{ .Labels.namespace }}</code>
{{- end }}
{{- if .Labels.pod }}
📦 Pod: <code>{{ .Labels.pod }}</code>
{{- end }}
{{- if .Labels.container }}
🐳 Container: <code>{{ .Labels.container }}</code>
{{- end }}
{{- if .Labels.node }}
🖥 Node: <code>{{ .Labels.node }}</code>
{{- end }}
{{- if .Labels.instance }}
🖥 Instance: <code>{{ .Labels.instance }}</code>
{{- end }}
{{- if .Labels.job }}
🔧 Job: <code>{{ .Labels.job }}</code>
{{- end }}
{{- if eq .Status "firing" }}
🕐 Since: <code>{{ .StartsAt | date "2006-01-02 15:04 MST" }}</code>
{{- else }}
🕐 Resolved: <code>{{ .EndsAt | date "2006-01-02 15:04 MST" }}</code>
{{- end }}
{{- end }}
{{- end }}