top of page

Setting up AlertManager with Docker Compose

Updated: Jun 21, 2023

What is AlertManager?

The Alertmanager sends alerts to various channels like Slack or E-Mail.

Recall from part one that Prometheus creates an alert if something violates a rule. You can use the Alertmanager to silence and group alerts as well.


You can get all source code from GitHub. Check out the tag `part-2-grafana` if you want to follow along.


First of all, add the Alertmanager and a volume to docker-compose.yml:

    image: prom/alertmanager:v0.23.0
    restart: unless-stopped
      - "9093:9093"
      - "./alertmanager:/config"
      - alertmanager-data:/data
    command: --config.file=/config/alertmanager.yml --log.level=debug


Alertmanager will persist silence configurations to the volume.


This configuration contains information about which channels to send to. For simplicity, we use e-mail. Refer to the Alertmanager docs to learn about other channels.

Create a folder alertmanager and add a file alertmanager.yml to it:

  receiver: 'mail'
  repeat_interval: 4h
  group_by: [ alertname ]

  - name: 'mail'
      - smarthost: ''
        auth_username: ''
        auth_password: ""
        from: ''
        to: ''

The `route` section configures which alerts will be sent. In our case, we sent all alerts. You could add more routes and filter, for example, on alert tags (see the example in the docs.).

receivers configures our target channels. Note how route refers to the receiver mail on line two. You will get a new mail every four hours until the problem is solved.

Connect to Prometheus

Finally, we need to tell Prometheus about the Alertmanager. Open prometheus/prometheus.yml and add the following:

    - scheme: http
        - targets: [ 'alertmanager:9093' ]


Run docker-compose up.

Open http://localhost:9093 in your browser to see the Alertmanager UI.

Setting up AlertManager with Docker Compose

After a couple of minutes, the test alert fires. You can check this in your Prometheus instance.

Setting up AlertManager with Docker Compose

Now, you can see the alert in the Alertmanager as well:

Setting up AlertManager with Docker Compose

Check your inbox for the notification:

Setting up AlertManager with Docker Compose

7,713 views0 comments


Rated 0 out of 5 stars.
No ratings yet

Add a rating
Stationary photo

Be the first to know

Subscribe to our newsletter to receive news and updates.

Thanks for submitting!

Follow us
bottom of page