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'

 

posted @   冷夜O  阅读(765)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
点击右上角即可分享
微信分享提示