[Synthetics] Can't get custom labels from checks on alerts

Hello!

We are evaluating Grafana Cloud Synthetics, and I have created many MultiHTTP checks. I’ve added a few custom labels to each one, like:

  • environment
  • application
  • slack_channel

To be able to use these labels, I’ve created a template like the one below on Alerting->Notification Points->Templates, using some examples on the documentation :

{{ define "slack_test" }}
{{ range .Alerts }}
{{ $alert := . }}
{{ range .Labels.SortedPairs }}
{{ .Name }} = {{ .Value }}
{{/* works because $alert refers to the value of dot inside the first range */}}
There are {{ len $alert.Labels }}
{{ end }}
{{ range .Annotations.SortedPairs }}
The name of the annotation is {{ .Name }}, and the value is {{ .Value }}
{{ end }}
{{ end }}
{{ end }}

Then, on Contact Point, I’ve configured the slack integration, and put this on the "message body’:

{{ template "slack.default.text" . }}
{{ template "slack_test" . }}

Very nice, this worked, the template is parsed and I’ve got the notification on slack, but on the labels loop, the custom labels I have defined on the MultiHTTP check is not shown, only default labels like alertname, alert_sensitivity, instance, job, namespace and type (which is a custom label, but defined on the “SyntheticMonitoringCheckFailureAtHighSensitivity” alert on the Synthetics, it’s not on the MultiHTTP check.

Then i’ve tried looping over other variables mentioned on the docs: GroupLabels and CommonLabels, like below:

{{ define "slack_test" }}
{{ range .Alerts }}
{{ $alert := . }}
{{ range .Labels.SortedPairs }}
{{ .Name }} = {{ .Value }}
{{/* works because $alert refers to the value of dot inside the first range */}}
There are {{ len $alert.Labels }}
{{ end }}
{{ range .Annotations.SortedPairs }}
The name of the annotation is {{ .Name }}, and the value is {{ .Value }}
{{ end }}
{{ range .CommonLabels.SortedPairs }}
The name of the CommonLabels is {{ .Name }}, and the value is {{ .Value }}
{{ end }}
{{ range .GroupLabels.SortedPairs }}
The name of the GroupLabels is {{ .Name }}, and the value is {{ .Value }}
{{ end }}
{{ end }}
{{ end }}

But when using that template, I simply get no message notification on slack when the alert fires. If I remove the added part from the template, the notification works again. So I’m assuming some error parsing the template is ocurring, but I suppose in Grafana Cloud we have no way to check logs or something like that to further investigate these errors.

[Edit]
I’ve also tried getting the label in a custom annotation on the alert, but it doesn’t work, the variable $labels.slack_channel come empty.

If anyone knows how to get custom labels defined on MultiHTTP checks, give me some guidance,please!

Thanks,
Claudio Neves