Alert with multiple values that are firing, I see only the first one in the message

I’m having a weird issue, I have an alert that is firing with more than one value, but the alert reports only the first and not the other:

That’s working fine:

But I receive only the first value, the others values that are firing are disappeared.

My AlertValues inside the alert:

{{ with $values }}{{ if $values.C }}{{$ }}: {{ $values.B.Value | printf "%.0f" }}W
{{ end }} {{ end }}

My templates:

{{ define "mymessage" }}{{ if gt (len .Alerts.Firing) 0 }}⚠️{{ range .Alerts.Firing }} {{ template "myalert" .}}{{ end }}
  {{ end }}{{ if gt (len .Alerts.Resolved) 0 }}❇️{{ range .Alerts.Resolved }} {{ template "myalert" .}}
  {{ end }}
  {{ end }}
{{ end }}
{{define "myalert"}}{{range .Annotations.SortedPairs}}{{.Value}}
  {{ if gt (len .PanelURL ) 0 }}Panel: {{ .PanelURL }}{{ end }}
  {{ if gt (len .DashboardURL ) 0 }}Dashboard: {{ .DashboardURL }}
  {{ end }}
  {{range .Labels.SortedPairs}}
  {{.Name }}: {{.Value }} {{ end }}
  {{ if gt (len .Annotations) 0 }}
 Silence alert: {{ .SilenceURL }}{{ end }}
{{ end }}


Hi! I’m a little confused, as we talking about the values in AlertValues, or the number of alerts in a notification?

1 Like

The number of the alerts/values in the notification, I mean, the notification alert should have more than one value (3) inside, according to the alert configuration.

But instead inside the notification I’m receiving only one value (the first).

The push notification should be one with the three values that are firing.

I hope you are understanding now, sorry!

Hi! It looks like AlertValue is an annotation with the following template:

{{ with $values }}{{ if $values.C }}{{$ }}: {{ $values.B.Value | printf "%.0f" }}W
{{ end }} {{ end }}

This template will mean that each alert will have one label and value. For example:

Computer: 789W

Depending on the grouping in your notification policy, and the number of alerts that are firing at any point in time, you may get one alert per notification, or multiple alerts per notification. However, each alert in any notification will only have one value in the AlertValues annotation.

I hope this helps!

1 Like

This was my issue, I corrected the “grouping” policy to disabled and now I’m receveing one notification for every value, as I need!