From ae67899bcf674313ec0b5c4971ebb253c5d1a5de Mon Sep 17 00:00:00 2001 From: Erich Blume Date: Sun, 22 Mar 2026 11:26:51 -0700 Subject: [PATCH] C2(deploy-infra-alerting): impl fix ntfy payload template syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use confirmed Grafana 12 template functions (coll.Dict, coll.Slice, coll.Append, data.ToJSON) to build ntfy-native JSON payload. Previous attempt hit 400 from ntfy — likely malformed output from incorrect template syntax. This version uses the documented patterns from Grafana's notification template reference. Co-Authored-By: Claude Opus 4.6 (1M context) --- argocd/manifests/grafana/alerting.yaml | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/argocd/manifests/grafana/alerting.yaml b/argocd/manifests/grafana/alerting.yaml index 7f60749..ae9e891 100644 --- a/argocd/manifests/grafana/alerting.yaml +++ b/argocd/manifests/grafana/alerting.yaml @@ -88,15 +88,16 @@ templates: name: ntfy-infra template: | {{ define "ntfy-infra.payload" -}} - {{ $msg := "" -}} - {{ range .Alerts -}} - {{ $msg = printf "%s%s\n" $msg .Annotations.summary -}} - {{ 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 }} + {{- $msg := "" -}} + {{- range .Alerts -}} + {{- $msg = (printf "%s%s\n" $msg .Annotations.summary) -}} + {{- end -}} + {{- $title := (printf "[%s] %s" (.Status | toUpper) .CommonLabels.alertname) -}} + {{- $actions := coll.Slice -}} + {{- range .Alerts -}} + {{- if .Annotations.runbook_url -}} + {{- $actions = coll.Append (coll.Dict "action" "view" "label" "Open Runbook" "url" .Annotations.runbook_url) $actions -}} + {{- end -}} + {{- end -}} + {{- coll.Dict "topic" "infra-alerts" "title" $title "message" $msg "priority" 3 "actions" $actions | data.ToJSON -}} + {{- end }}