Files
nexus/wiki/entities/Alertmanager.md
2026-04-22 04:03:04 +08:00

76 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Alertmanager"
type: entity
aliases: [Prometheus Alertmanager, Alertmanager OSS]
tags: [alerting, prometheus, notification, devops, observability]
date: 2025-11-11
---
# Alertmanager
## Overview
Alertmanager 是 Prometheus 生态系统中的告警分发和路由组件。当 Prometheus 的告警规则触发时,告警被发送给 Alertmanager由 Alertmanager 负责抑制inhibition、分组grouping、静默silencing和路由routing到最终的通知通道邮件、Slack、PagerDuty、WeChat 等)。
## Key Characteristics
- **告警分组**:将相似告警合并为一条通知,避免告警风暴
- **抑制机制**:当一个严重告警触发时,自动抑制相关的次要告警
- **静默规则**:基于时间窗口的告警静默,支持重复告警抑制
- **多通道路由**邮件、Slack、WeChat、Telegram、PagerDuty、Webhook
- **重复间隔**:未解决的告警按可配置间隔重复发送
## Prometheus Configuration
```yaml
# prometheus.yml
alerting:
alertmanagers:
- static_configs:
- targets: ['alertmanager:9093']
```
## Alertmanager Configuration
```yaml
# alertmanager/config.yml
global:
resolve_timeout: 5m
route:
receiver: default
group_wait: 10s # 新告警等待 10s 再发送(收集同组告警)
group_interval: 5m # 告警组更新间隔
repeat_interval: 3h # 重复告警间隔
receivers:
- name: default
email_configs:
- to: "youremail@example.com"
from: "monitor@example.com"
smarthost: "smtp.example.com:587"
auth_username: "monitor@example.com"
auth_password: "yourpassword"
# Slack 配置示例
slack_configs:
- api_url: 'https://hooks.slack.com/services/xxx'
channel: '#alerts'
```
## Alertmanager vs Grafana Alerting
| 维度 | Alertmanager | Grafana Alerting |
|------|-------------|-----------------|
| 数据源 | Prometheus 原生 | 多数据源 |
| 告警规则 | Prometheus YAML | Grafana UI / YAML |
| 通知通道 | 原生多通道 | 原生 + 插件扩展 |
| 告警历史 | 需额外存储 | 内置告警历史 |
| 适用场景 | 标准化告警 | 仪表盘联动告警 |
## Related Sources
- [[家庭监控方案-prometheus-grafana-node-exporter-cadvisor-blackbox]]
## Related Entities
- [[Prometheus]] — 告警规则源和发送方
- [[Grafana]] — 可替代 Prometheus Alerting 的告警方案
## Related Concepts
- [[Prometheus告警规则]] — 告警条件定义
- [[PromQL]] — 告警触发条件语言
- [[System Monitoring]] — 上游应用领域