Alertmanager logs `template: ... executing "slack.default.text" ... map has no entry for key`
IntermediateTroubleshootingAlerting and Alertmanager
Answer
Likely causes → Custom template indexes a label that some alerts lack.
Diagnose → Find the alert missing the label in the UI.
Fix → Guard the template: {{ if .Labels.service }}{{ .Labels.service }}{{ else }}unknown{{ end }}, or use {{ index .Labels "service" }} which returns empty instead of failing.
Prevent → Render templates against sample alerts in CI.
More on Alerting and Alertmanager
An alert shows `Pending` in Prometheus but never goes to `Firing`BeginnerAn alert is `Firing` in Prometheus but nothing reaches AlertmanagerIntermediateAlertmanager shows the alert but Slack receives nothingBeginnerAlertmanager logs `notify retry canceled due to unrecoverable error after 1 attempts: channel_not_found`IntermediateAlertmanager logs `unexpected status code 404: no_service` / `invalid_token` for SlackBeginnerAlertmanager fails to load config: `yaml: unmarshal errors: field matchers not found in type config.plain`Intermediate