Alertmanager Config Generator

Generate production-ready alertmanager.yml with receivers, routing trees, inhibition rules, silences, and templates.

Global Configuration

SMTP Require TLS
alertmanager.yml
1global:
2 resolve_timeout: 5m
3 smtp_smarthost: 'smtp.example.com:587'
4 smtp_from: 'alertmanager@example.com'
5 smtp_auth_username: 'alertmanager@example.com'
6 smtp_auth_password: 'password'
7 smtp_require_tls: true
8
9route:
10 receiver: 'slack-general'
11 group_by: ['alertname', 'cluster', 'service']
12 group_wait: 30s
13 group_interval: 5m
14 repeat_interval: 4h
15 routes:
16 -
17 receiver: 'pagerduty-critical'
18 group_by: ['alertname', 'cluster']
19 group_wait: 30s
20 group_interval: 5m
21 repeat_interval: 4h
22 matchers:
23 - severity='critical'
24 -
25 receiver: 'slack-warning'
26 group_by: ['alertname', 'service']
27 group_wait: 30s
28 group_interval: 5m
29 repeat_interval: 4h
30 matchers:
31 - severity='warning'
32
33receivers:
34 - name: 'slack-receiver'
35 slack_configs:
36 - api_url: 'https://hooks.slack.com/services/...'
37 channel: '#alerts'
38 title: '{{ .GroupLabels.alertname }}'
39 text: '{{ range .Alerts }}{{ .Annotations.description }}{{ end }}'
40 - name: 'pagerduty-receiver'
41 pagerduty_configs:
42 - service_key: 'your-pagerduty-integration-key'
43 severity: 'critical'
44 description: '{{ .GroupLabels.alertname }}'
45
46inhibit_rules:
47 - source_matchers:
48 - severity='critical'
49 target_matchers:
50 - severity='warning'
51 equal: ['alertname', 'instance']
52
53templates:
54 - '/etc/alertmanager/templates/*.tmpl'
55
56# Template: /etc/alertmanager/templates/slack.tmpl
57{{ define "slack.custom.title" }}
58[{{ .Status | toUpper }}{{ if eq .Status "firing" }}:{{ .Alerts.Firing | len }}{{ end }}] {{ .GroupLabels.SortedPairs.Values | join " | " }}
59{{ end }}
60
61{{ define "slack.custom.message" }}
62{{ range .Alerts }}
63*Alert:* {{ .Labels.alertname }}{{ if .Labels.severity }} - `{{ .Labels.severity }}`{{ end }}
64*Description:* {{ .Annotations.description }}
65*Details:*
66{{ range .Labels.SortedPairs }} • *{{ .Name }}:* `{{ .Value }}`
67{{ end }}{{ end }}
68{{ end }}
Health
Security
Best Practices

Overview

The Alertmanager Configuration Generator helps you build production-grade alertmanager.yml files for routing, grouping, and delivering Prometheus alerts. Alertmanager handles deduplication, grouping, inhibition, and silencing of alerts before sending notifications to email, Slack, PagerDuty, Microsoft Teams, and more.

Alertmanager sits between your Prometheus server and your notification channels. When Prometheus fires alerts, Alertmanager receives them, groups related alerts together, applies inhibition rules to suppress lower-severity alerts, checks for active silences, and routes notifications to the correct receivers based on your routing tree configuration.

How It Works

1. Global Configuration: Define SMTP settings, HTTP client options, and resolve_timeout that applies to all alert resolutions. These globals are inherited by all receivers unless overridden.

2. Route Tree: The routing tree determines which receiver handles each alert. The root route defines defaults, and child routes use matchers to split alerts by severity, team, service, or any label. Routes can be nested to create complex routing hierarchies.

3. Receivers: Each receiver defines one or more notification integrations. Configure Slack webhooks, PagerDuty service keys, email SMTP settings, Teams webhook URLs, or custom webhook endpoints. Multiple receivers can send the same alert to different channels.

4. Inhibition Rules: Inhibition rules suppress notifications for lower-severity alerts when a higher-severity alert is firing. For example, suppress warning alerts when a critical alert for the same service is already active, reducing alert noise during incidents.

5. Silences: Temporarily suppress notifications for specific alerts during maintenance windows or known outages. Silences use label matchers and have start/end timestamps with an optional comment and creator.

6. Templates: Customize notification text using Go template syntax. Reference alert labels, annotations, and group information to create informative, actionable notifications.

Best Practices

  • Use hierarchical routing with matchers to direct alerts to the appropriate team and severity level instead of a single catch-all receiver.
  • Configure group_by with meaningful labels like alertname, cluster, and service to reduce notification noise during cascading failures.
  • Set repeat_interval to at least 4 hours to avoid alert fatigue from repeated notifications on persistent issues.
  • Use inhibit_rules to suppress lower-severity alerts when critical alerts fire, reducing noise during incidents.
  • Deploy Alertmanager in a cluster of 3 or more instances with mesh gossip protocol for high availability and automatic deduplication.
  • Use templates to include runbook links and actionable context in every notification, reducing mean time to resolution.
  • Store SMTP credentials and API keys in environment variables or secret managers, never in the alertmanager.yml file.
  • Test your routing tree with amtool before deploying to production to catch misconfigurations early.

Common Mistakes

  • Forgetting to set repeat_interval on the root route, causing alerts to re-notify every minute and creating alert fatigue.
  • Using match instead of matchers in route configuration, which causes silent routing failures in newer Alertmanager versions.
  • Not configuring group_wait, leading to individual alert notifications instead of grouped batches during cascading failures.
  • Hardcoding API keys and passwords directly in alertmanager.yml instead of using environment variable substitution.
  • Deploying a single Alertmanager instance without clustering, which creates a single point of failure for all alerting.

Security Recommendations

  • Never commit alertmanager.yml with plaintext passwords or API keys. Use environment variable substitution with $SMTP_PASSWORD syntax.
  • Enable TLS on the Alertmanager web UI and API endpoints when exposed to the network.
  • Use basic authentication or reverse proxy auth to protect the Alertmanager API from unauthorized silence creation.
  • Restrict network access to Alertmanager receivers (Slack webhooks, PagerDuty endpoints) using firewall rules.
  • Run Alertmanager as a non-root user with read-only filesystem mounts where possible.

Production Tips

  • Deploy Alertmanager in a 3-node cluster using the --cluster.peer flag for gossip-based membership and automatic deduplication.
  • Use a dedicated Prometheus rule file to route alerts to Alertmanager with proper labels for routing decisions.
  • Monitor Alertmanager itself with Prometheus metrics: alertmanager_notifications_total, alertmanager_cluster_members, and queue sizes.
  • Configure external labels on Prometheus to enable cross-datacenter alert routing through a global Alertmanager federation.
  • Use amtool to validate configuration, check routing trees, and manage silences from the command line.
  • Set up a dead-man's switch alert (always firing) to verify your entire alerting pipeline is working end-to-end.

Frequently Asked Questions

What is Alertmanager and how does it relate to Prometheus?
Alertmanager is a standalone tool that handles alerts sent by Prometheus. It groups similar alerts, deduplicates notifications across Alertmanager instances, applies inhibition rules, and routes notifications to configured receivers like Slack, PagerDuty, or email. Prometheus evaluates alerting rules and sends firing alerts to Alertmanager via HTTP.
How does the Alertmanager routing tree work?
The routing tree starts with a root route that defines default receivers and grouping. Child routes add matchers to filter alerts by labels (severity, team, service). Alertmanager walks the tree top-down, and the first matching route handles the alert. Continue can be set to allow alerts to match multiple routes.
What are Alertmanager inhibition rules?
Inhibition rules suppress notifications for target alerts when source alerts are firing. For example, if a critical alert is active for a service, you can inhibit warning alerts for the same service. This reduces alert noise during incidents by preventing duplicate notifications at different severity levels.
How do I deploy Alertmanager in high availability?
Run 3 or more Alertmanager instances with the --cluster.peer flag pointing to other members. They use gossip protocol to share state, deduplicate alerts automatically, and ensure notifications are sent only once even if multiple instances receive the same alert.
Can I customize Alertmanager notification templates?
Yes. Alertmanager uses Go templates in the templates section. You can reference alert labels (.Labels), annotations (.Annotations), and group information (.GroupLabels) to create custom notification text. Templates are referenced in receiver configurations for each notification channel.
How do I create silences in Alertmanager?
Use the Alertmanager web UI, amtool command-line tool, or the API to create silences. Define matchers to specify which alerts to silence, set start and end times, and add a comment explaining why the silence is active. Silences are stored in Alertmanager's internal state and expire automatically.
What is the difference between group_wait and group_interval?
group_wait is the initial delay before sending the first notification for a new group of alerts (default 30s). group_interval is the minimum time between notifications for the same group (default 5m). Together they control how alerts are batched and when follow-up notifications are sent.
How does Alertmanager handle HA deduplication?
Alertmanager instances in a cluster share alert state via gossip protocol. When multiple instances receive the same alert, they elect one to send the notification. The cluster uses a consensus mechanism so only one instance sends each notification, preventing duplicate alerts to your team.

Related Generators