I think you want something very similar to what I suggested here. I’ve changed it below to better match your situation.
-
Instead of using Classic Conditions change the alert rule to use Reduce expression and then either a Threshold or Math expression. This will allow you to use
$labels
in both annotations and notification templates. -
Add a summary description to your alert rule with the following template:
{{ index $labels "log" }}
- Create a custom notification template like this and use it in your contact point:
{{ define "alert.summarize" -}}
{{ index .Labels "alertname" }}: {{ index .Annotations "summary" }}
{{- end }}
{{ define "alerts.summarize" -}}
{{ if .Alerts.Firing }}{{ len .Alerts.Firing }} firing alert(s)
{{ range .Alerts.Firing -}}
{{ template "alert.summarize" . }}
{{ end }}{{ end }}
{{ if .Alerts.Resolved }}{{ len .Alerts.Resolved }} resolved alert(s)
{{ range .Alerts.Resolved -}}
{{ template "alert.summarize" . }}
{{ end }}{{ end }}
{{ end }}