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 }}