Slack Alert Template is not picking up the labels

I am creating a Slack alert template with all the labels I want, but the alert is not populating the values of those labels.

{{ define "slack.message" }}
Additional Details:
  - Name: {{ .Labels.alertname }}
{{ end }}

Below is the state I want to be in but even the single label is not populating from the alert.

{{ define "slack.title" }}
  *Severity:* `{{ .Labels.severity }}`
  *Cluster:* `{{ .Labels.cluster }}`
  *Summary:* {{ .Annotations.summary }}
  *Description:* {{ .Annotations.description }}
  *Additional Details:*
    - *Name:* `{{ .Labels.alertname }}`
    - *Pod:* `{{ .Labels.pod }}`
    - *Namespace:* `{{ .Labels.namespace }}`
    - *Service:* `{{ .Labels.service }}`
    - *Container:* `{{ .Labels.container }}`
    - *Endpoint:* `{{ .Labels.endpoint }}`
    - *Route:* `{{ .Labels.route }}`
    - *Method:* `{{ .Labels.method }}`
    - *Status-Code:* `{{ .Labels.status_code }}`
{{ end }}

Below is the labels I see from Alert.

This is how I see the alert after applying the simple slack template with just alert name in it.

Thanks

Hi @rohanjadhav1,

In the notification template, the dot (.) is initiliazed with the Notification data object. The .Labels property in the Notification data, but in the Alert object.

You should first access the list of alerts via .Alerts. Then, print the properties of the individual alerts.

This example that prints some alert data may be helpful. Here’s another one:

{{ define "custom_slack_message" }}
{{ range .Alerts}}
   - Name: {{ .Labels.alertname }}
{{ end }}
{{ end }}