How I can customize alertmanager notifications in slack to show environment labels? Do you have any solutions?
you can use something like this in prometheus config:
scrape_interval: 30s
scrape_timeout: 10s
evaluation_interval: 30s
external_labels:
environment: production```
slack config:
```slack_configs:
- send_resolved: true
http_config: {}
api_url: <secret>
channel: '#alerts'
username: '{{ template "slack.default.username" . }}'
color: '{{ if eq .Status "firing" }}warning{{ else }}good{{ end }}'
title: '[{{ if eq .Status "firing" }}{{ .Alerts.Firing | len }} {{ end }} {{ if
eq .Status "firing" }}Alerts{{ else }}{{ .Status | toUpper }}{{ end }}]'
title_link: '{{ template "slack.default.titlelink" . }}'
pretext: '{{ .CommonAnnotations.summary }}'
text: |-
{{ range .Alerts }}
{{- if .Annotations.summary }}*Alert:* {{ .Annotations.summary }}{{- end }}
*Description:* {{ .Annotations.description }}{{ .Annotations.message }}
*environment:* `{{ .Labels.environment }}`
*Severity:* `{{ .Labels.severity }}`
{{ end }}
footer: '{{ template "slack.default.footer" . }}'
fallback: '{{ template "slack.default.fallback" . }}'
callback_id: '{{ template "slack.default.callbackid" . }}'
icon_emoji: '{{ template "slack.default.iconemoji" . }}'
icon_url: '{{ template "slack.default.iconurl" . }}'```