Alertmanager setup with docker-compose.

Full monitoring stack — part 3.

Mirco | VerboseMode.dev
Javarevisited
2 min readOct 27, 2021

--

Please read the updated version here:

In short: 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.

Configuration

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

docker-compose.yml

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

Alertmanager will persist silence configurations to the volume.

alertmanager/alertmanager.yml

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:

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:

Testing

Run docker-compose up.

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

Alertmanager UI after start.

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

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

Check your inbox for the notification:

Final note

This series shows how to set up a basic Prometheus stack. Keep in mind that this is not production-ready! But it is enough to get your hands dirty.

--

--