Prometheus Alertmanager 模块添加短信告警
总阅读量:2227次
摘要: 原创出处 jianshu.com/p/128e4751404e 「pigness」欢迎转载,保留摘要,谢谢!
AlertManager用于接收Prometheus发送的告警并对于告警进行一系列的处理后发送给指定的用户。系统的整体设计图如下面所示,并且支持HA高可用部署。
1. 下载可编译版本的 AlertManager
git clone https://github.com/prometheus/alertmanager.git |
2. 在 notify.go 中添加 sms 新标签
numNotifications.WithLabelValues("sms") //新增标签 |
3. 在 config.go 中添加新配置项
SMSConfigs []*SMSConfig `yaml:"sms_configs,omitempty" json:"sms_configs,omitempty"` |
4. 在 notifiers.go 中添加 config 的详细定义
// SMSConfig configures notifications via sms. |
具体字段可根据实际情况修改
5. 参照 webhook 进行自定义的 notify 逻辑编写 自定义的notify路由需要满足该Notifier接口,实现Notify方法。 比如下面是webhook的实现,首先定义一个管理webhook的结构体Webhook,包含基本的配置和模板信息,WebhookMessage定义了发送webhook的信息
// Webhook implements a Notifier for generic webhooks. |
6. 修改 alertmanager.yml 相关配置进行告警调用
|