{{ define "template" }}
host {{ .Labels.alertname }} has been caused by {{ .Labels.host }}
{{ .Annotations.Summary }}
{{ end }}
But the alert is only sent up to the first label
This is the error log:
logger=alerting.notifier.slack level=error msg="Missing receiver"
logger=alerting.notifier.slack level=error msg="Missing group labels"
logger=alerting.notifier.slack lvl=warn msg="failed to template Slack message" err="template: template:3:15: executing \"template\" at <.Labels.alertname>: can't evaluate field Labels in type *channels.ExtendedData"
Can you confirm: are you using the new Grafana Alerting platform (first released in Grafana 8) or the legacy alerting platform? I should note that the legacy platform is no longer actively developed:
An alert message may contain a collection of alerts instead of a single object. You should first {{ range .Alerts }} before calling other template variables or use {{ (index .Alerts 0) }} if you only care about the first alert message. I’d suggest using the range clause.
If you want to get to the query response labels, you’ll want access them in the values map you see in the alert preview. There’s more in the other post if that’s what you’re after.