[prometheus]Step7-prometheus使用阿里云企业邮箱告警

prometheus使用阿里云企业邮箱告警

修改/data/alertmanager/alertmanager.yml 加入邮件配置

# 全局配置项
global:
  resolve_timeout: 5m # 处理超时时间,默认为5min
  smtp_from: 'seafile@pdabc.com'
  smtp_smarthost: 'smtp.mxhichina.com:465'
  smtp_auth_username: 'seafile@pdabc.com'
  smtp_auth_password: '${password}'
  smtp_require_tls: false


# 定义路由树信息
route:
  group_by: [alertname]  # 报警分组依据
  receiver: ops_notify   # 设置默认接收人
  group_wait: 30s        # 最初即第一次等待多久时间发送一组警报的通知
  group_interval: 60s    # 在发送新警报前的等待时间
  repeat_interval: 1h    # 重复发送告警时间。默认1h
  routes:

  - receiver: ops_notify  # 基础告警通知
    group_wait: 10s
    match_re:
      alertname: 实例存活告警|磁盘使用率告警   # 匹配告警规则中的名称发送

  - receiver: info_notify  # 消息告警通知
    group_wait: 10s
    match_re:
      alertname: 内存使用率告警|CPU使用率告警

# 定义基础告警接收者
receivers:
- name: ops_notify
  webhook_configs:
  - url: http://localhost:8060/dingtalk/ops_dingding/send
    send_resolved: true  # 警报被解决之后是否通知
  email_configs:
  # - to: '423308591@qq.com‘  如果两个邮箱中间需要空格
  - to: '423308591@qq.com, hugo.xu@pdabc.com'
    send_resolved: true

# 定义消息告警接收者
- name: info_notify
  webhook_configs:
  - url: http://localhost:8060/dingtalk/info_dingding/send
    send_resolved: true

# 一个inhibition规则是在与另一组匹配器匹配的警报存在的条件下,使匹配一组匹配器的警报失效的规则。两个警报必须具有一组相同的标签。
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']

修改完毕之后重启alertmanager服务

systemctl  restart   alertmanager
systemctl  status   alertmanager

然后关闭某台主机测试 钉钉和邮件同时告警

如果发送失败 可以使用下面命令查看日志

journalctl -f -u alertmanager

通知两个邮箱

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爷来辣

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值