Skip to main content
This guide explains how to add Alertmanager routing and receiver configurations using the Prometheus Operator’s AlertmanagerConfig custom resource (CRD). AlertmanagerConfig objects let you register Alertmanager configuration snippets (routes, groupings, receivers) with an Alertmanager instance running in Kubernetes.

Example AlertmanagerConfig

This example demonstrates a simple route and a webhook receiver. Save it as a YAML file when creating the CRD.
This structure mirrors an Alertmanager configuration: a route, grouping settings, and one or more receivers. When deployed as a Kubernetes CRD, the AlertmanagerConfig will only be registered with an Alertmanager instance if that Alertmanager is configured to select it (selectors explained below).

Alertmanager selector settings you must know

The kube-prometheus-stack (and other Prometheus Operator installs) exposes two selector properties in the Alertmanager CR:
  • alertmanagerConfigSelector — controls which AlertmanagerConfig objects in the same namespace are selected.
  • alertmanagerConfigNamespaceSelector — controls which namespaces’ AlertmanagerConfig objects are selectable.
If these selectors are empty, Alertmanager will not pick up any AlertmanagerConfig resources. Inspect your Alertmanager CR with:
Typical default spec shows empty selectors:
To enable automatic registration of AlertmanagerConfig objects, configure the Helm chart values so the Alertmanager’s alertmanagerConfigSelector matches the labels you add to your AlertmanagerConfig resources.

Key differences: Alertmanager YAML vs AlertmanagerConfig CRD

There are two important differences between a standalone alertmanager.yml and the AlertmanagerConfig CRD: Examples for matcher and field naming differences: Standalone Alertmanager YAML (snake_case + simple matchers):
AlertmanagerConfig CRD (camelCase + explicit matchers):
When converting an existing Alertmanager alertmanager.yml to an AlertmanagerConfig CRD, convert snake_case fields to camelCase and convert simple label matchers into matchers objects with name and value.

Enable AlertmanagerConfig discovery in the Helm chart

Follow these steps to configure the kube-prometheus-stack Helm chart so Alertmanager automatically discovers AlertmanagerConfig resources.
  1. Export the chart’s default values:
  1. Edit values.yaml and add an alertmanagerConfigSelector so it matches the label you will use on your AlertmanagerConfig resources. For example, to match resource: prometheus:
Note: If your chart organizes Alertmanager settings under a nested key (for example alertmanager:), place the selector under the appropriate key according to that chart’s values structure.
  1. Upgrade the release with the modified values file:
  1. Verify the Alertmanager CR now contains the selector you configured:
You should see an updated spec like:

Create and apply an AlertmanagerConfig

Create a file named alert.yaml containing the AlertmanagerConfig example. Ensure the metadata.labels include the label the Alertmanager will select (in the example above, resource: prometheus):
Apply it:
Verify creation:
If you receive an error that the resource type does not exist, ensure the Prometheus Operator CRDs (including alertmanagerconfigs.monitoring.coreos.com) are installed in your cluster.

Verify Alertmanager picked up the config

Port-forward the Alertmanager service and open the UI to confirm the config was registered:
On the Alertmanager Status -> Config page you should see the webhook receiver and the routes created via your AlertmanagerConfig CRD.

Troubleshooting tips

  • If your AlertmanagerConfig does not appear in Alertmanager:
    • Confirm the Alertmanager’s alertmanagerConfigSelector matches the label on your AlertmanagerConfig.
    • Confirm the namespace of the AlertmanagerConfig is selected by alertmanagerConfigNamespaceSelector if set.
    • Confirm Prometheus Operator CRDs are installed and up to date.
  • Use kubectl describe on the Alertmanager and AlertmanagerConfig resources to see events and errors.
  • Check Alertmanager logs (via Pod logs) for registration errors.

Watch Video

Practice Lab