From e7f50bc4fd415d4d8b5d4e3a633d0cc190c3b044 Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Sun, 22 Mar 2026 11:18:37 -0700 Subject: [PATCH] C2(deploy-infra-alerting): impl use custom payload for ntfy-native JSON Replace Grafana's default webhook JSON with ntfy-native JSON via payloadTemplate. The template produces: {"topic":"infra-alerts","title":"[FIRING] ...","message":"...","actions":[...]} This gives clean notifications instead of raw Grafana JSON blobs. Uses coll.Dict/data.ToJSON template functions (Grafana 12+). Co-Authored-By: Claude Opus 4.6 (1M context) --- argocd/manifests/grafana/alerting.yaml | 27 +++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/argocd/manifests/grafana/alerting.yaml b/argocd/manifests/grafana/alerting.yaml index a05ddee..7f60749 100644 --- a/argocd/manifests/grafana/alerting.yaml +++ b/argocd/manifests/grafana/alerting.yaml @@ -7,13 +7,11 @@ contactPoints: - uid: ntfy-infra-webhook type: webhook settings: - url: https://ntfy.ops.eblu.me/infra-alerts + url: https://ntfy.ops.eblu.me httpMethod: POST - title: >- - {{ template "ntfy-infra.title" . }} - message: >- - {{ template "ntfy-infra.message" . }} maxAlerts: "0" + payloadTemplate: >- + {{ template "ntfy-infra.payload" . }} disableResolveMessage: false policies: @@ -89,13 +87,16 @@ templates: - orgId: 1 name: ntfy-infra template: | - {{ define "ntfy-infra.title" -}} - [{{ .Status | toUpper }}] {{ .CommonLabels.alertname }} - {{- end }} - - {{ define "ntfy-infra.message" -}} + {{ define "ntfy-infra.payload" -}} + {{ $msg := "" -}} {{ range .Alerts -}} - {{ .Annotations.summary }} - {{ if .Annotations.runbook_url }}Runbook: {{ .Annotations.runbook_url }}{{ end }} + {{ $msg = printf "%s%s\n" $msg .Annotations.summary -}} {{ end -}} - {{- end }} + {{ $actions := coll.Slice -}} + {{ range .Alerts -}} + {{ if .Annotations.runbook_url -}} + {{ $actions = coll.Slice (coll.Dict "action" "view" "label" "Open Runbook" "url" .Annotations.runbook_url "clear" false) -}} + {{ end -}} + {{ end -}} + {{ data.ToJSON (coll.Dict "topic" "infra-alerts" "title" (printf "[%s] %s" (.Status | toUpper) .CommonLabels.alertname) "message" $msg "priority" 3 "actions" $actions) -}} + {{ end }}