Prometheus + Alertmanager: 30-Minute Tutorial
From zero to alerts firing into Slack. Covered in detail: install, instrumentation, alert rule, routing.
Step 1: Run Prometheus
docker run -d -p 9090:9090 -v $PWD/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus
Open localhost:9090.
Step 2: Instrument app
- Add a metrics endpoint to your app (Prometheus client lib).
- Configure scrape in
prometheus.yml. - Reload:
kill -HUP $(pidof prometheus).
Step 3: Write alert rule
Create alerts.yml with rule. Reference in prometheus.yml.
Reload Prometheus.
Verify in localhost:9090/alerts.
Step 4: Route to Slack
Run Alertmanager: docker run -d -p 9093:9093 prom/alertmanager
Configure Slack webhook in alertmanager.yml.
Trigger alert; verify in Slack.
Antipatterns
- Default scrape interval. Tune for your workload.
- No alert rule expiry. Pages forever.
- Alertmanager without grouping. Spam during cascade.
What to do this week
Three moves. (1) Run the tutorial end-to-end on your own laptop / sandbox. (2) Apply the pattern to one production workload. (3) Document the variations you needed; share with the team.