AlertmanagerConfig objects defined in Kubernetes follow the Prometheus Operator CRD schema and are mapped to Alertmanager configuration. They are not automatically discovered unless Alertmanager’s
alertmanagerConfigSelector (and optionally alertmanagerConfigNamespaceSelector) are configured to match your labels.Basic AlertmanagerConfig example
This is a minimal AlertmanagerConfig CRD that routes grouped alerts to a webhook receiver:metadata.labels— used to match this object to Alertmanager instances (viaalertmanagerConfigSelector).spec.route— route behavior (grouping and timing).spec.receivers— one or more receivers (here: webhook).
Why Alertmanager might not pick up your AlertmanagerConfig
When installed via the kube-prometheus-stack Helm chart, the Alertmanager StatefulSet/Deployment includes two fields in its spec:alertmanagerConfigSelector (and optionally alertmanagerConfigNamespaceSelector) in the chart values so Alertmanager can discover AlertmanagerConfig objects by label.
If you do not configure a selector in the Helm chart values, Alertmanager will ignore AlertmanagerConfig objects even if they exist in the cluster.
Important syntax differences: alertmanager.yml vs AlertmanagerConfig CRD
When converting analertmanager.yml (standalone Alertmanager config) to an AlertmanagerConfig CRD, note two common differences:
- Property naming: standalone
alertmanager.ymluses snake_case (e.g.,group_wait), while the CRD uses camelCase (e.g.,groupWait). - Label matchers: in
alertmanager.ymlyou can writejob: kubernetes. In the CRD matchers must be objects withnameandvalue.
Example pair:
alertmanager.yml
Configure the Helm chart so Alertmanager finds AlertmanagerConfig objects
- Retrieve the default values for the kube-prometheus-stack chart:
- Edit
values.yamland setalertmanagerConfigSelectorto match the labels you will use on AlertmanagerConfig objects. For example, to matchresource: prometheus:
- Upgrade the Helm release using the modified values file:
Create and apply an AlertmanagerConfig
Create a filealert.yaml with the same example CRD (note metadata.labels matches the Helm selector):
Verify the Alertmanager configuration in the UI
Port-forward to the Alertmanager service and inspect the configuration via the status page:- Find the Alertmanager service (commonly
alertmanager-operated):
- Port-forward to 9093:
- Open http://localhost:9093/ in your browser and inspect the “Status -> Configuration” page. You should see your webhook receiver and routing as part of the Alertmanager configuration generated from your AlertmanagerConfig CRD.
Troubleshooting tips
- If you see no AlertmanagerConfig objects in the Alertmanager UI but they exist in Kubernetes, re-check that:
- The Helm chart
alertmanagerConfigSelectormatches the labels on your AlertmanagerConfig objects. - If you used namespace selectors, ensure
alertmanagerConfigNamespaceSelectoris set appropriately.
- The Helm chart
- Use
kubectl get alertmanagers.monitoring.coreos.com -o yamlto inspect the Alertmanager CRD instance spec and verify selectors. - Review the operator logs (Prometheus Operator) for errors about parsing AlertmanagerConfig objects.
- kube-prometheus-stack Helm chart: https://github.com/prometheus-community/helm-charts
- Prometheus Operator AlertmanagerConfig CRD: https://github.com/prometheus-operator/prometheus-operator
- Kubernetes basics: https://kubernetes.io/docs/concepts/overview/what-is-kubernetes/