Summarise the grafana alerts

I am utilising an alerting system to track expiration dates for approximately 80 domains through a Prometheus data source. Currently, I receive email notifications for each of the five domains separately that will expire within the next 30 days. Instead, I’m looking for a consolidated list of all instances triggering alerts. Is this achievable? Additionally, I prefer to have only the instance label included in the email, excluding all other labels.

Hi team, can someone check on my requirement?

Hi,

yes it can be achieved.
What is your template of the alert and also the alert rule for this particular alert?

Regards,
Fadjar

HI Fadjuar,

Currently, I am not using any template for notification, using the default only. And alert rule is, if the expiry date of a domain is within 35 days, it should trigger an alert.

Hi, can someone check on this

I have used the following template and I can get only the instances names. But I want to add the value of A as well

Template

{{ define “ssltemplate” }}
Below listed domains SSL certificates are due for renewal and will expire within 35 days, please renew it
{{ range .Alerts }}
{{- range $key, $value := .Labels -}}
{{- if and (ne $key “alert_for”) (ne $key “alertname”) (ne $key “grafana_folder”) (ne $key “job”) }}
{{ $value }}
{{- end }}
{{- end }}
{{ end }}
{{ end }}

Try this:

{{ define “ssltemplate” }}
Below listed domains SSL certificates are due for renewal and will expire within 35 days, please renew it
{{ range .Alerts }}
{{- range $key, $value := .Labels -}}
{{- range $key, $value := .Values -}}
{{- if and (ne $key “alert_for”) (ne $key “alertname”) (ne $key “grafana_folder”) (ne $key “job”) }}
{{ $value }}
{{- end }}
{{- end }}
{{ end }}
{{ end }}

Now I cannot get both the label and it is value. This is my code

Hi,
I think my code was wrong.

Try this:

{{ define “ssltemplate” }}
Below listed domains SSL certificates are due for renewal and will expire within 35 days, please renew it
{{ range .Alerts }}
{{ range $key, $value := .Labels }}{{ $key }}={{ $value }} {{ end } }{{ range $key, $value := .Values }}{{ $key }}={{ $value }} {{ end }}
{{- if and (ne $key “alert_for”) (ne $key “alertname”) (ne $key “grafana_folder”) (ne $key “job”) }}
{{- end }}
{{- end }}
{{ end }}
{{ end }}

Getting the error - undefined variable $key

This is the code
{{ define “ssltemplate” }}

Below listed domains SSL certificates are due for renewal and will expire within 35 days, please renew it

{{ range .Alerts }}

{{ range $key, $value := .Labels }}{{ $key }}={{ $value }} {{ end }} {{ range $key, $value := .Values }}{{ $key }}={{ $value }} {{ end }}

{{- if and (ne $key “alert_for”) (ne $key “alertname”) (ne $key “grafana_folder”) (ne $key “job”) }}

{{- end }}

{{- end }}

{{ end }}

{{ end }}

Hi team, is there any update on this issue?