fix(alertmanager): quote null receiver and wire telegram template
Unquoted null parses as YAML null and breaks routing. Add shared telegram message template.
This commit is contained in:
1 parent
c98ea8b957
commit
5936de3e56
3 files changed
+56
-3
No files matched your search
@@ -1,5 +1,10 @@
|
||||
route:
|
||||
receiver: default
|
||||
routes:
|
||||
- receiver: "null"
|
||||
matchers:
|
||||
- alertname="Watchdog"
|
||||
|
||||
receivers:
|
||||
- name: default
|
||||
- name: "null"
|
||||
@@ -1,3 +1,6 @@
|
||||
templates:
|
||||
- "/etc/alertmanager/config/telegram.tmpl"
|
||||
|
||||
route:
|
||||
receiver: telegram
|
||||
group_by:
|
||||
@@ -7,10 +10,10 @@ route:
|
||||
group_interval: 5m
|
||||
repeat_interval: 12h
|
||||
routes:
|
||||
- receiver: null
|
||||
- receiver: "null"
|
||||
matchers:
|
||||
- alertname="InfoInhibitor"
|
||||
- receiver: null
|
||||
- receiver: "null"
|
||||
matchers:
|
||||
- alertname="Watchdog"
|
||||
|
||||
@@ -35,4 +38,5 @@ receivers:
|
||||
chat_id: REPLACE_WITH_TELEGRAM_CHAT_ID
|
||||
parse_mode: HTML
|
||||
send_resolved: true
|
||||
- name: null
|
||||
message: '{{ template "telegram.forust.message" . }}'
|
||||
- name: "null"
|
||||
@@ -0,0 +1,44 @@
|
||||
{{- 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 }}
|
||||
Reference in new issue
Block a user