Configuring Alertmanager to Send Alerts via Email, Slack, and PagerDuty
Introduction
Alertmanager supports multiple notification methods to ensure alerts reach the right teams quickly. This article covers configuring Email, Slack, and PagerDuty as receivers.
Email Configuration
Set up the Email receiver in your alertmanager.yml:
receivers:
- name: 'team-email'
email_configs:
- to: '[email protected]'
from: '[email protected]'
smarthost: 'smtp.example.com:587'
auth_username: '[email protected]'
auth_password: 'yourpassword'
require_tls: true
Slack Configuration
To send alerts to Slack, create a Slack webhook URL, then configure the receiver:
receivers:
- name: 'team-slack'
slack_configs:
- api_url: 'https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX'
channel: '#alerts'
send_resolved: true
PagerDuty Configuration
Integrate with PagerDuty by creating a service integration key, then configure Alertmanager:
receivers:
- name: 'team-pagerduty'
pagerduty_configs:
- service_key: 'your-pagerduty-service-integration-key'
severity: 'error'
send_resolved: true
Routing Configuration
Define routes to send alerts to the appropriate receivers based on labels or priorities:
route:
group_by: ['alertname', 'priority']
group_wait: 30s
group_interval: 5m
repeat_interval: 3h
receiver: 'team-email'
routes:
- match:
severity: 'critical'
receiver: 'team-pagerduty'
- match:
team: 'devops'
receiver: 'team-slack'
Reload Alertmanager
After updating alertmanager.yml, reload Alertmanager to apply the new configuration:
kill -HUP $(pidof alertmanager)
Summary
This configuration ensures alerts are routed effectively through Email, Slack, and PagerDuty, improving incident response and collaboration.