介绍
在第二篇中(原文链接)介绍了alert manager的安装,这篇文章是基于这个内容的扩展
AlertManager Config
使用Alertmanager CRD 创建AlertManager时,有两种加载配置文件方式
官方文档:https://prometheus-operator.dev/docs/developer/alerting/
1 | alertmanagerConfiguration: |
alertmanagerConfiguration
:全局配置
alertmanagerConfigSelector
:基于命名空间的配置
非全局会添加基于命名空间的条件,告警规则必须存在这个lable,以下两者生成alertmanager配置的区别
1 | route: |
邮件告警
创建发件邮箱
略
测试邮箱发件(阿里邮箱)
1
2
3
4
5
6curl --url 'smtps://smtp.vsoul.cn' \
--mail-from '[email protected]' \
--mail-rcpt '[email protected]' \
--user '[email protected]:YOUR_PASSWORD' \
--ssl-reqd --insecure \
-T <(printf 'From: VSoul 通知 <[email protected]>\nTo: [email protected]\nSubject: 测试邮件发送')
创建AlertManagerConfig
1 | apiVersion: monitoring.coreos.com/v1alpha1 |
创建告警规则
测试规则
1 | apiVersion: monitoring.coreos.com/v1 |
收到告警即为成功