As its name implies, "CommonLabels" contains only those labels which are common to all alerts in the group. If there are multiple instances, then the "instance" label is not common to all alerts, so won't be in this object.
You want to iterate over "Alerts" (or "Alerts.Firing") and look at the Labels.instance within each alert. You will find an example showing how to do that here: https://prometheus.io/docs/alerting/latest/notification_examples/#ranging-over-all-received-alerts Additional references: https://prometheus.io/docs/alerting/latest/notifications/#data https://prometheus.io/docs/prometheus/latest/configuration/template_reference/ On Tuesday, 6 June 2023 at 12:03:03 UTC+1 Kolja Krückmann wrote: > Currently my alertmanager.yml looks like this: > > receivers: > - name: 'email' > email_configs: > - to: '[email protected]' > send_resolved: true > headers: > Subject: '{{ .CommonLabels.alertname }} - {{ .CommonLabels.instance > }}' > > Unfortunately the subject in the mail now only displays both labels if > only there is an alert for a single instance (like High CPU Usage on core > 0,1,2,3 on one instance (see screenshot attatched)) As soon as the alert is > for more then just one instance the instance lable is completly missing... > Why is it missing? And how can I change it to display all instances > affected by that alert. > > Kind regards. > Kolja > > [image: mail.png] > > Kolja Krückmann schrieb am Montag, 5. Juni 2023 um 09:21:22 UTC+2: > > Hi y'all > I'm trying to change the way the mail from my alertmanger looks and > behaves. > My goal is to have the subject list the alertname and the targets detected > by that alert. (I need it like that for future todo's) > My first problem is, i dont have any templates in my files. Do I need to > clone one from git? How does the prom know, I have a template? > The second one would be to change the subject in order for my requirements > to fit. > > Kind regards, > Kolja > > -- You received this message because you are subscribed to the Google Groups "Prometheus Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/996d8510-5fb8-4de8-aaba-679bf7e45baen%40googlegroups.com.

