Hello,
Can someone help me, I’m having a little trouble with an email template.
I have the following template who brings me a fine subject for my email
Code:
{{ define “correo.asunto2” }}
{{ if len .Alerts }}
[Warning] Alerta de CPU elevado - AWS
{{ end }}
{{ if len .Alerts.Resolved }}
[Resuelto] Alerta de CPU elevado - AWS
{{ end }}
{{ end }}
Subject for email:
I want to replace the text in the condition with variables sets on the alert rule, but I recieve the subject duplicated when another alert trigger
Code:
{{ define “correo.asunto2” }}
{{ if len .Alerts }}
{{range .Alerts }} [{{.Labels.criticidad}}] {{.Labels.Asunto}} - {{.Labels.ambiente}} {{end}}
{{ end }}
{{ if len .Alerts.Resolved }}
{{range .Alerts }} [Resuelto] {{.Labels.Asunto}} - {{.Labels.ambiente}} {{end}}
{{ end }}
{{ end }}
Subject for email:
The subject duplicate the text when two alerts triggers, and it continuously grows if more alerts triggers.
I’m pretty sure is because the following function {{ range .Alerts }}, if someone have an alternative in order to have an generic subject.
Thanks!
Grafana ver: 10.0