What is Alertmanager?
Alertmanager sends alerts (e.g., email/Slack) when Prometheus metrics satisfy configured conditions.
Installation
You can spin up Prometheus with Docker Compose using this repo: → Install docker-compose
Start with:
$ git clone https://github.com/vegasbrianc/prometheus
$ cd prometheus
$ docker-compose up
Ports:
Prometheus | http://localhost:9090/ |
Alertmanager | http://localhost:9093/ |
Slack notifications
Create a Slack app for Prometheus, enable Incoming Webhooks, and get the webhook URL.
Set username
, channel
, and api_url
in alertmanager/config.yml
:
route:
receiver: 'slack'
receivers:
- name: 'slack'
slack_configs:
- send_resolved: true
username: '<username>'
channel: '<channel name>'
api_url: '<webhook url>'
Alertmanager configuration
Define alert rules like this:
groups:
- name: <rule name>
rules:
- alert: <alert name>
expr: <PromQL expression>
for: <duration>
severity: <severity>
annotations:
description: "Alert description"
summary: "Summary"
alert | Alert name |
expr | PromQL expression |
for | How long the condition must hold (s, m, h, d) |
severity | Severity (e.g., critical, warning) |
annotations | Description and summary |
In this repo, rules live in prometheus/alert.rules
.
To force an example alert, set expr
to 1 as below:
groups:
- name: rule-example
rules:
- alert: alert-example
expr: 1
for: 1m
After editing, restart the Docker containers to apply changes. After a short wait, http://localhost:9090/alerts shows the alert as active.

Status is PENDING or FIRING; FIRING means the alert is firing.
Alertmanager shows fired alerts:

Slack also receives the notification:
