06alertmanager配置邮件触发告警
配置前提:
1.部署好prometheus,alertmanager
2.配置好告警规则,alertmanager要先可以接收到告警
一.配置alertmanager
1.查看alertmanager.yml配置文件
2.添加发送人邮箱
global: resolve_timeout: 5m smtp_from: '163xxxxxx@qq.com' smtp_smarthost: 'smtp.qq.com:465' smtp_auth_username: '163xxxx@qq.com' smtp_auth_password: 'mlaatixxxxxehac' smtp_require_tls: false smtp_hello: 'qq.com'
smtp_auth_password:是你qq邮箱开通的第三方授权码
smtp_require_tls:false 是关闭tls
3.添加邮箱路由
route: group_by: ['alertname'] group_wait: 30s group_interval: 5m repeat_interval: 1h receiver: 'email'
receiver:添加对应的接收器
4.设置接收器
receivers: - name: 'web.hook' webhook_configs: - url: 'http://127.0.0.1:5001/' - name: 'email' email_configs: - to: '195xxxxxxx@139.com' send_resolved: true
send_resolved:设置为true,则告警恢复后会发送邮件通知
重启alertmanager.
二.测试
cat /del/zero > /del/null
通过压测cpu使用率使告警生效。
告警发送邮件
告警恢复邮件
三.添加多个收件人
逗号隔开写上邮箱地址。
- to : 'xxx123@163.com,xxx456@qq.com'
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构