feat(grafana): custom emoji message templates per alert + resolve format

Each alert rule's summary annotation now renders a formatted Telegram
message with emoji and multiline context. The contact point passes the
pre-rendered summary through, adding " Resuelto" on resolution.
Also restores the == 1 filter on Pod Failed/Unknown lost in prior rebase.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 07:26:01 +00:00
parent 4facdd8515
commit 4897ca3334
+6 -5
View File
@@ -16,6 +16,7 @@ data:
bottoken: "${TELEGRAM_BOT_TOKEN}" bottoken: "${TELEGRAM_BOT_TOKEN}"
chatid: "5138407666" chatid: "5138407666"
parseMode: HTML parseMode: HTML
message: "{{ range .Alerts }}{{ if eq .Status \"firing\" }}{{ .Annotations.summary }}\n{{ else }}✅ Resuelto: {{ .Labels.alertname }}\n{{ end }}{{ end }}"
disableResolveMessage: false disableResolveMessage: false
notification-policy.yaml: | notification-policy.yaml: |
@@ -48,7 +49,7 @@ data:
noDataState: OK noDataState: OK
execErrState: Error execErrState: Error
annotations: annotations:
summary: "CrashLoopBackOff: {{ $labels.pod }} ({{ $labels.namespace }})" summary: "🔄 CrashLoop: {{ $labels.pod }}\nNamespace: {{ $labels.namespace }}"
description: "Container {{ $labels.container }} ha entrado en CrashLoopBackOff." description: "Container {{ $labels.container }} ha entrado en CrashLoopBackOff."
labels: labels:
severity: critical severity: critical
@@ -89,7 +90,7 @@ data:
noDataState: NoData noDataState: NoData
execErrState: Error execErrState: Error
annotations: annotations:
summary: "Disco lleno: {{ $labels.mountpoint }} en {{ $labels.instance }}" summary: "💾 Disco casi lleno: {{ $labels.mountpoint }}\nUso: {{ humanizePercentage $values.B.Value }}"
description: "Filesystem {{ $labels.mountpoint }} supera el 80% de uso." description: "Filesystem {{ $labels.mountpoint }} supera el 80% de uso."
labels: labels:
severity: warning severity: warning
@@ -130,7 +131,7 @@ data:
noDataState: NoData noDataState: NoData
execErrState: Error execErrState: Error
annotations: annotations:
summary: "RAM alta: {{ $labels.instance }}" summary: "🧠 RAM alta: {{ $labels.instance }}\nUso: {{ humanizePercentage $values.B.Value }}"
description: "Uso de RAM supera el 85% en {{ $labels.instance }}." description: "Uso de RAM supera el 85% en {{ $labels.instance }}."
labels: labels:
severity: warning severity: warning
@@ -171,7 +172,7 @@ data:
noDataState: OK noDataState: OK
execErrState: Error execErrState: Error
annotations: annotations:
summary: "Pod en estado {{ $labels.phase }}: {{ $labels.pod }} ({{ $labels.namespace }})" summary: "🚨 Pod caído: {{ $labels.pod }}\nNamespace: {{ $labels.namespace }}\nEstado: {{ $labels.phase }}"
description: "Pod {{ $labels.namespace }}/{{ $labels.pod }} lleva más de 3 minutos en estado {{ $labels.phase }}." description: "Pod {{ $labels.namespace }}/{{ $labels.pod }} lleva más de 3 minutos en estado {{ $labels.phase }}."
labels: labels:
severity: warning severity: warning
@@ -182,7 +183,7 @@ data:
datasourceUid: prometheus datasourceUid: prometheus
model: model:
editorMode: code editorMode: code
expr: "kube_pod_status_phase{phase!~\"Running|Succeeded\"}" expr: "kube_pod_status_phase{phase!~\"Running|Succeeded\"} == 1"
instant: true instant: true
refId: A refId: A
- refId: B - refId: B