Prometheus Alertmanager Tutorial: Routing, Grouping and Slack Alerts

Prometheus Alertmanager Tutorial: Routing, Grouping and Slack Alerts

Prometheus is excellent at deciding that something is wrong. It evaluates alert rules against your metrics, and when a condition holds it fires an alert. But Prometheus does not decide who should hear about it, how many messages they should get, or when to stop repeating itself. That is the job of Alertmanager, the companion component that takes every firing alert and turns it into the right notification, sent to the right person, at the right frequency.

Without Alertmanager, a single incident becomes a flood. A database goes down and every service that depends on it starts firing its own alert, each one arriving as a separate message. With Alertmanager configured well, the same incident produces one clear page for the database team and silence for the symptoms. This tutorial builds that setup from scratch: installing Alertmanager, designing a routing tree, grouping alerts, adding Slack and PagerDuty receivers, writing inhibition rules, and testing the configuration before it handles a real incident.

What Alertmanager Does and How Alerts Flow

Alertmanager sits between Prometheus and the people who respond to incidents. Prometheus evaluates alerting rules and sends firing alerts to Alertmanager, re-sending them at regular intervals while they continue to fire. Alertmanager then runs each alert through a pipeline of decisions: the routing tree picks a receiver, grouping collects related alerts into a single notification, inhibition and silences remove alerts that should not notify right now, and the receiver formats and delivers what is left. Nothing in this pipeline changes whether the alert is firing. An inhibited or silenced alert is still firing in Prometheus and still visible in the Alertmanager interface as suppressed. Suppression only affects notifications.

Understanding this flow matters because most Alertmanager confusion comes from expecting one mechanism to do another mechanism’s job. Routing decides where a notification goes. Grouping decides how many notifications a set of alerts becomes. Inhibition decides which alerts are hidden because a more important alert already explains them. Silences decide which alerts are muted for a fixed period, usually during planned maintenance. Time intervals decide when a route is allowed to notify at all, for example muting low severity alerts overnight. Each mechanism is independent, and a good configuration uses all of them for different purposes rather than forcing one to cover everything.

Alertmanager also deduplicates and remembers what it has sent. When Prometheus re-sends a firing alert, Alertmanager recognizes it as the same alert and does not notify again until the group changes or the repeat interval passes. This notification log is part of why Alertmanager can be restarted without re-sending every active alert, and it is also why running Alertmanager in a cluster replicates silences and the notification log between instances using a gossip protocol. Our Prometheus and Grafana monitoring tutorial covers the Prometheus side of this stack, including writing alert rules and building dashboards, so if you have not set up Prometheus itself yet, start there and return here once your first alert is firing.

Installing Alertmanager and Connecting Prometheus

Alertmanager is a single binary with no dependencies beyond its configuration file, which makes installation straightforward. Download the release for your operating system from the Prometheus download page, extract it, and run the binary with the path to your configuration file. For a first setup on a test machine, a minimal configuration with a single receiver is enough to prove the connection works before you add routing complexity.

# Download and extract Alertmanager, then start it
tar xvfz alertmanager-*.linux-amd64.tar.gz
cd alertmanager-*.linux-amd64
./alertmanager --config.file=alertmanager.yml

By default Alertmanager listens on port 9093, and its web interface is available at that port. The interface shows active alerts, silences, and the current configuration, which makes it the first place to look when a notification does not arrive. Alertmanager can reload its configuration at runtime without restarting: sending a SIGHUP to the process or an HTTP POST to the reload endpoint triggers a reload, and if the new configuration is not well formed the changes are not applied and an error is logged.

Before writing a real configuration, create the smallest one that can work. This file defines a root route with one receiver and a webhook receiver that prints what it receives, which lets you confirm end to end delivery before you involve Slack or PagerDuty.

global:
  resolve_timeout: 5m

route:
  receiver: webhook-receiver

receivers:
  - name: webhook-receiver
    webhook_configs:
      - url: 'http://127.0.0.1:5001/webhook'
        send_resolved: true

The resolve_timeout setting is the documented default of five minutes, and it controls how long Alertmanager waits before marking an alert resolved when Prometheus stops sending it. The send_resolved option tells the receiver whether to send a message when the alert resolves, which is how your team learns that an incident is over rather than only that it started. Start Alertmanager with this file, then point Prometheus at it by adding an alerting section to your Prometheus configuration file.

# prometheus.yml — tell Prometheus where Alertmanager lives
global:
  scrape_interval: 15s
  evaluation_interval: 15s

rule_files:
  - rules.yml

alerting:
  alertmanagers:
    - static_configs:
        - targets:
            - localhost:9093

scrape_configs:
  - job_name: prometheus
    static_configs:
      - targets: ['localhost:9090']

Now add a simple alert rule that you can trigger on demand, so you can watch the whole path work. The official Alerting based on metrics tutorial uses a counter metric and fires when it passes a threshold, which is the same pattern used here. Create a rule that fires when a test metric stays high, reload Prometheus, and check the Alertmanager interface to confirm the alert arrives.

# rules.yml — a simple rule you can trigger for testing
groups:
  - name: test-alerts
    rules:
      - alert: TestAlertFiring
        expr: up == 0
        for: 1m
        labels:
          severity: warning
          team: platform
        annotations:
          summary: 'A monitored target is down'
          description: 'The target {{ $labels.instance }} has been down for more than one minute.'

The Routing Tree: Matching Alerts to Receivers

The routing tree is the heart of Alertmanager. It is a tree of routes, each with matchers that select which alerts it handles and a receiver that gets the resulting notifications. The root route has no matchers, because every alert must land somewhere, and its receiver is the default for anything that matches no child route. Child routes are tried in order, and an alert goes to the first child whose matchers all match, then continues down into that child’s own children. If no child matches, the parent route handles the alert. This first match wins behavior is the single most important rule in the whole system, and getting the order wrong is the most common routing mistake.

Matchers use the same syntax as PromQL label matchers, written as a list of strings. The older match and match_re maps are deprecated in favor of matchers, which also support negative matches, so new configurations should use matchers throughout. A matcher such as severity = critical selects alerts carrying that exact label value, while team != platform selects alerts that do not carry that team. You can combine several matchers on one route, and all of them must match for the route to apply. Children inherit the grouping and timing settings of their parent unless they override them, which keeps the configuration compact when several teams share the same timing but use different receivers.

Start with a two level tree: team at the top, severity inside. This structure stays readable as you add teams, because each team’s routes live in one place and the severity split is identical everywhere. The example below routes critical alerts from the web team to a paging receiver, warning alerts from the same team to Slack, and everything else to a default Slack channel.

route:
  receiver: default-slack
  group_by: ['alertname', 'service']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 4h
  routes:
    - matchers:
        - team = web
      receiver: web-slack
      routes:
        - matchers:
            - severity = critical
          receiver: web-pager
    - matchers:
        - team = data
      receiver: data-slack
      routes:
        - matchers:
            - severity = critical
          receiver: data-pager
    - matchers:
        - severity = critical
      receiver: default-pager

That deliberate change is continue: true. Setting it on a route makes matching carry on to the following sibling routes after the first match, so one alert can notify several receivers. Use it sparingly, because it is how a single alert ends up paging two teams and landing in three channels at once. The legitimate uses are narrow: a critical alert that should page the owning team and also notify a central incident channel, or an alert that should reach both a team channel and a compliance log. When you use it, add a comment explaining why, because the next person to read the file will otherwise assume the duplication is a mistake. The Alertmanager configuration reference documents the full route schema, including matchers, grouping, timing, and the continue flag, and it is the authoritative source when a directive behaves differently from what you expected.

# Show the routing tree and test where an alert would go
amtool check-config /etc/alertmanager/alertmanager.yml
amtool config routes show --config.file=/etc/alertmanager/alertmanager.yml
amtool config routes test --config.file=/etc/alertmanager/alertmanager.yml \
  severity=critical team=web alertname=HighErrorRate
amtool config routes test --config.file=/etc/alertmanager/alertmanager.yml \
  severity=warning team=unknown alertname=DiskFillingUp

Grouping and Timing: Turning Many Alerts Into One Message

Grouping is what stops ten instances of the same problem from becoming ten separate messages. Alerts on the same route that share the same values for the labels listed in group_by become one notification group, and the group is notified as a single message listing all its alerts. A typical choice is group_by: ['alertname', 'service'], which produces one message per alert name per service. If ten web servers all report high error rates, the web team gets one message listing all ten instead of ten messages arriving over two minutes. If you group only by alert name, unrelated services get bundled into the same message, which confuses the reader. If you group by every label, which the special value ['...'] does, grouping is effectively disabled and every alert notifies separately.

Three timing settings control when a group notifies. group_wait is how long a new group waits before its first notification, so alerts that arrive together can be batched into the first message instead of trickling in one by one. Thirty seconds is a common value, and it works because most alerts from a single root cause arrive within a few seconds of each other. group_interval is how long Alertmanager waits before sending a follow up notification when new alerts join an existing group. Five minutes is a common value, and it means a group that keeps growing sends an update every few minutes rather than one message per new alert. repeat_interval is how long Alertmanager waits before re-sending a notification for a group that has not changed. Four hours is a common value for warnings, while paging routes often use a shorter interval so that an unresolved critical alert re-pages rather than going quiet.

Choosing these values is a trade off between speed and noise, and the right answer depends on severity. A critical alert should notify quickly, so a short group wait matters more than batching. A warning alert can wait longer, because nobody is woken up by it and a batched message is easier to read. Set different values per route rather than one global set: pages get a short wait and a short repeat interval, Slack warnings get a longer wait and a long repeat interval, and informational alerts get the longest of all. Remember that children inherit timing from their parent, so set the defaults at the root and override only where a route genuinely needs different behavior. Ask the team that receives the notifications what interval they actually want, and revisit the answer after the first month of real incidents.

Receivers: Slack, PagerDuty, Email and Webhooks

A receiver defines where notifications go and how they are formatted. Alertmanager supports many receiver types, including email, Slack, PagerDuty, Opsgenie, VictorOps, Pushover, Telegram, and generic webhooks, and a single configuration can use several of them at once. Each receiver has its own configuration block, and each block can set send_resolved to control whether resolved notifications are sent. The Slack receiver is the most common starting point, because most teams already live in Slack and a channel message is the lowest friction way to see an alert.

To send Slack notifications you need an incoming webhook URL for the channel, created in the Slack app settings. Store the URL in a file and reference it with slack_api_url_file rather than writing it directly in the configuration, so the secret does not end up in source control. The receiver can set a channel, a username, and a message template, and the default template already includes the alert name, labels, and annotations, which is enough for a first version. The example below sends critical alerts to one channel and everything else to another, with resolved notifications enabled so the team sees when an incident ends.

global:
  resolve_timeout: 5m
  slack_api_url_file: /etc/alertmanager/slack_webhook

receivers:
  - name: web-slack
    slack_configs:
      - channel: '#alerts-web'
        send_resolved: true
        title: '{{ range .Alerts }}{{ .Annotations.summary }}{{ end }}'
        text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'
  - name: default-slack
    slack_configs:
      - channel: '#alerts-general'
        send_resolved: true

PagerDuty receivers work differently, because PagerDuty manages the on call rotation and escalation itself. The Alertmanager receiver needs an integration key, which you create in PagerDuty as a Prometheus integration on the service that should receive the pages. The receiver can set the severity, the client name, and a link back to the Alertmanager interface or to your runbook, and PagerDuty turns the notification into an incident with its own acknowledgement and escalation rules. This is the right tool for alerts that must wake someone up, because Slack messages are easy to miss at night and email is worse. Reserve PagerDuty for alerts that genuinely need a human immediately, and keep everything else in Slack, or the rotation burns out and pages start being ignored.

receivers:
  - name: web-pager
    pagerduty_configs:
      - service_key: 'your-pagerduty-integration-key'
        send_resolved: true
        client: 'Alertmanager'
        client_url: 'http://alertmanager.example.com:9093'
        description: '{{ range .Alerts }}{{ .Annotations.summary }}{{ end }}'
        severity: '{{ range .Alerts }}{{ .Labels.severity }}{{ end }}'

Webhook receivers are the escape hatch for everything else. A webhook receiver sends a JSON payload to any HTTP endpoint, which means you can forward alerts to a ticketing system, a custom dashboard, or a chat tool without a built in receiver. The payload includes the alert labels, annotations, status, and links, so the receiving service has everything it needs to act. When you add a receiver, test it with a real firing alert, not just a configuration check, because a valid configuration can still fail to deliver if the webhook URL is wrong or the channel name is misspelled. Our Grafana dashboard tutorial shows how to build the dashboards your team will open from these notifications.

Inhibition Rules: Suppressing Symptoms When the Cause Is Known

Inhibition is the mechanism that stops one failure from generating dozens of notifications about its consequences. An inhibition rule says that while a source alert is firing, target alerts that match the rule should not notify. The classic example is a node going down: the node down alert is the root cause, and the alerts about high CPU, failed health checks, and refused database connections on that same node are symptoms. Without inhibition the team receives all of them. With inhibition they receive one message about the node, and the symptom alerts wait silently until the node recovers.

A rule has three parts. source_matchers select the alert that does the suppressing. target_matchers select the alerts that can be suppressed. equal lists the labels whose values must be identical between the source and the target for suppression to apply. That last part is what makes inhibition precise rather than dangerous: a node down alert for one host should not suppress alerts for a different host, and the equal list is what prevents that. The rule below suppresses every alert in a cluster while the cluster down alert fires, and suppresses instance level alerts on a node while that node’s down alert fires.

inhibit_rules:
  - source_matchers:
      - alertname = ClusterDown
    target_matchers:
      - severity = warning
    equal: ['cluster']
  - source_matchers:
      - alertname = NodeDown
    target_matchers:
      - severity =~ 'warning|critical'
    equal: ['instance']
  - source_matchers:
      - alertname = DatabaseDown
    target_matchers:
      - alertname =~ 'HighLatency|ConnectionErrors'
    equal: ['service']

Three properties of inhibition deserve attention. First, inhibition only affects notifications. The target alert keeps firing in Prometheus, it stays visible in the Alertmanager interface marked as inhibited, and it will notify normally once the source alert resolves. Second, inhibition is based on labels, not on topology. Alertmanager does not know that a database and a web server depend on each other unless their alerts share labels that express that relationship, so the equal list and the matchers are doing all the work. Third, an inhibited alert that was already notified before the source alert fired is not retracted. The team will have seen the symptom message and then the root cause message, which is acceptable, because the alternative is delaying every notification to check for a root cause that may never arrive.

Silences, Time Intervals and Testing Your Configuration

Silences are temporary, deliberate suppressions created at runtime rather than written in the configuration file. You create one when a team is already working on a problem and does not need more messages about it, or when planned maintenance will trigger alerts that everyone already expects. A silence has matchers, a start time, an end time, and a comment explaining why it exists, and it applies to alerts whose labels match. Unlike inhibition, a silence is created through the web interface, the API, or amtool, and it expires on its own, so it cannot be forgotten in the configuration file and suppress alerts forever.

# Create a two hour silence for a maintenance window
amtool silence add --alertmanager.url=http://localhost:9093 \
  --comment 'Database maintenance, team is aware' \
  --start 2026-12-03T10:00:00Z --end 2026-12-03T12:00:00Z \
  alertname=DatabaseDown instance=db-01

# List active silences and expire one early
amtool silence query --alertmanager.url=http://localhost:9093
amtool silence expire --alertmanager.url=http://localhost:9093 <silence-id>

Time intervals are the configuration file version of the same idea. A time interval defines days and times when a route may notify, and a route that references it through mute_time_intervals stays quiet outside those hours. This is useful for low severity alerts that can wait until business hours, while critical alerts keep paging around the clock. The older active_time_intervals setting does the reverse, allowing notifications only inside the interval. Define the interval once at the top level and reference it by name from any route that needs it.

time_intervals:
  - name: business-hours
    time_intervals:
      - weekdays: ['monday:friday']
        times:
          - start_time: '09:00'
            end_time: '17:00'

route:
  receiver: default-slack
  routes:
    - matchers:
        - severity = info
      receiver: default-slack
      mute_time_intervals:
        - business-hours

Testing ties all of this together. Before any configuration change reaches production, run amtool check-config to validate the syntax, use amtool config routes test to confirm routing for each team and severity, and fire a real test alert to confirm that the receiver actually delivers. Keep the configuration in source control and review changes like application code, with a second person checking the route order and the equal lists in inhibition rules. If you run Alertmanager as a cluster, configure Prometheus to send alerts to every instance directly rather than through a load balancer, so each instance can deduplicate correctly. Our SRE interview questions and answers guide covers the incident response thinking behind this tooling.

Frequently Asked Questions

What is the difference between Prometheus and Alertmanager?

Prometheus evaluates alert rules against metrics and decides when a condition is true. Alertmanager receives those firing alerts and decides what happens next: which receiver gets notified, how alerts are grouped, which ones are inhibited or silenced, and when to repeat a notification. Prometheus on its own cannot send a Slack message or page anyone. Alertmanager on its own cannot evaluate a metric. They are designed to work as a pair, and most production setups run both.

Why are my alerts firing in Prometheus but not reaching Slack?

Work through the pipeline in order. First confirm the alert is firing in Prometheus and that Prometheus is configured with the Alertmanager target. Then check the Alertmanager interface to see whether the alert arrived and whether it is marked as inhibited or silenced. Then use amtool to test which route and receiver the alert’s labels select. Finally, check the receiver itself: a wrong webhook URL or a misspelled channel name will fail the configuration check silently but produce an error in the Alertmanager log.

How should I choose group_by labels?

Choose labels that identify one incident. Alert name plus service is a good starting point, because one message per alert per service is easy to read and act on. Add environment or cluster when the same service runs in several places and the team needs to tell them apart. Avoid labels with many distinct values, such as instance or pod name, because each distinct value creates a separate group and the batching benefit disappears. Avoid grouping by alert name alone, because unrelated services will be bundled into a single confusing message.

When should I use inhibition instead of a silence?

Use inhibition for predictable relationships that are always true, such as a node failure suppressing the symptoms on that node. Inhibition rules live in the configuration file, apply automatically, and never expire. Use a silence for temporary situations, such as planned maintenance or an incident the team is already handling, where the suppression should end on its own. If you find yourself creating the same silence repeatedly, that is a sign the situation is predictable enough to deserve an inhibition rule or a fix to the alert rule itself.

Do I need to run Alertmanager in high availability mode?

For a single team or a test setup, one instance is enough, and it is the right place to start. For production alerting that pages people, run three instances as a cluster so that losing one does not lose silences or the notification log. Each instance must be configured in Prometheus as a separate target, and the instances gossip state between themselves. High availability protects the notification path, but it does not fix a bad routing tree, so get the configuration right on a single instance first and add clustering once the routing is proven.

Conclusion

Alertmanager earns its place by turning a stream of firing alerts into a small number of clear, actionable notifications. The routing tree decides who hears about each alert, grouping decides how many messages an incident becomes, receivers decide how the message arrives, inhibition hides the symptoms when the cause is already known, and silences pause notifications during work the team already knows about. None of these mechanisms is complicated on its own, and the whole system is a single configuration file that you can test with amtool before it ever handles a real page.

Start with the minimal configuration in this tutorial, prove the path works with a test alert, and then add one mechanism at a time: a team route, a Slack receiver, a PagerDuty receiver for critical alerts, and a single inhibition rule for the incident you most recently lived through. Check the route tests after every change, keep the configuration in source control, and ask the people who receive the notifications whether the messages are useful. Alerting is a feedback loop between the team and the configuration, and the setups that work best are the ones that keep being adjusted as the team learns what it actually needs to hear.

Scroll to Top