feiyu563 / PrometheusAlert

Prometheus Alert是开源的运维告警中心消息转发系统,支持主流的监控系统Prometheus,Zabbix,日志系统Graylog和数据可视化系统Grafana发出的预警消息,支持钉钉,微信,华为云短信,腾讯云短信,腾讯云电话,阿里云短信,阿里云电话等
https://feiyu563.gitbook.io
MIT License
2.85k stars 678 forks source link

怎能配置多个dingding 告警 #188

Closed trestea closed 2 years ago

trestea commented 2 years ago

prometheusalert 版本:v4.6.1 prometheusalert 配置:

---------------------↓webhook-----------------------

是否开启钉钉告警通道,可同时开始多个通道0为关闭,1为开启

open-dingding=1

默认钉钉机器人地址

ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxxxx

是否开启 @所有人(0为关闭,1为开启)

dd_isatall=1

怎么配置多个ddurl让alertmanager router选择哪个发送。

Zhang21 commented 2 years ago

你在prometheus rules中写上不同的地址就可以了。

annotations:
  wxurl: webhook1,webhook2...
trestea commented 2 years ago

@Zhang21 如果按照您这种写法,所有消息都会发送到2个webhook 我的意思是 根据路由特征 分别调用 不同的 钉钉通道。

trestea commented 2 years ago

我的告警配置是使用alertmanager --> prometheusAlert

trestea commented 2 years ago

alertmanager配置: receivers:

feiyu563 commented 2 years ago

你是想要这样的吧

global:
  resolve_timeout: 5m
route:
  group_by: ['instance']
  group_wait: 10m
  group_interval: 10s
  repeat_interval: 10m
  receiver: 'web.hook.prometheusalert'
  routes:
  - receiver: 'prometheusalert-weixin'
    group_wait: 10s
    match:
      level: '1'
  - receiver: 'prometheusalert-dingding'
    group_wait: 10s
    match:
      level: '2'
  - receiver: 'prometheusalert-feishu'
    group_wait: 10s
    match:
      level: '3'
  - receiver: 'prometheusalert-ruliu'
    group_wait: 10s
    match:
      level: '3'
  - receiver: 'prometheusalert-all'
    group_wait: 10s
    match:
      level: '4'
receivers:
- name: 'web.hook.prometheusalert'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/alert'
- name: 'prometheusalert-weixin'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?wxurl=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx'
- name: 'prometheusalert-dingding'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxxxx'
- name: 'prometheusalert-feishu'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?fsurl=https://open.feishu.cn/open-apis/bot/hook/xxxxxxxxx'
- name: 'prometheusalert-ruliu'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?groupid=123456'
- name: 'prometheusalert-all'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?wxurl=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx&ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxxxx&email=123@qq.com&phone=15395105573'
trestea commented 2 years ago
global:
  resolve_timeout: 5m
route:
  group_by: ['instance']
  group_wait: 10m
  group_interval: 10s
  repeat_interval: 10m
  routes:
  - receiver: 'dingding1'
    group_wait: 10s
    match:
      level: '1'
  - receiver: 'dingding2'
    group_wait: 10s
    match:
      level: '2'
receivers:
- name: dingding1
webhook_configs:
- url: http://prometheus-alert-center:8080/prometheusalert?type=dd&tpl=prometheus-dd&dd1url=https://oapi.dingtalk.com/robot/send?access_token=12bff15df40673b96230e5147afa9104706ea02cd622b507
send_resolved: true

- name: dingding2
  webhook_configs:
  - url: http://prometheus-alert-center:8080/prometheusalert?type=dd&tpl=prometheus-dd&dd2url=https://oapi.dingtalk.com/robot/send?access_token=b0d66a012b673b96230e5147afa9104706ea02cd622b507
    send_resolved: true

这样配置,prometheusAlert 怎么配置多个钉钉

trestea commented 2 years ago

你是想要这样的吧

global:
  resolve_timeout: 5m
route:
  group_by: ['instance']
  group_wait: 10m
  group_interval: 10s
  repeat_interval: 10m
  receiver: 'web.hook.prometheusalert'
  routes:
  - receiver: 'prometheusalert-weixin'
    group_wait: 10s
    match:
      level: '1'
  - receiver: 'prometheusalert-dingding'
    group_wait: 10s
    match:
      level: '2'
  - receiver: 'prometheusalert-feishu'
    group_wait: 10s
    match:
      level: '3'
  - receiver: 'prometheusalert-ruliu'
    group_wait: 10s
    match:
      level: '3'
  - receiver: 'prometheusalert-all'
    group_wait: 10s
    match:
      level: '4'
receivers:
- name: 'web.hook.prometheusalert'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/alert'
- name: 'prometheusalert-weixin'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?wxurl=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx'
- name: 'prometheusalert-dingding'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxxxx'
- name: 'prometheusalert-feishu'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?fsurl=https://open.feishu.cn/open-apis/bot/hook/xxxxxxxxx'
- name: 'prometheusalert-ruliu'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?groupid=123456'
- name: 'prometheusalert-all'
  webhook_configs:
  - url: 'http://[prometheusalert_url]:8080/prometheus/router?wxurl=https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx&ddurl=https://oapi.dingtalk.com/robot/send?access_token=xxxxx&email=123@qq.com&phone=15395105573'

你发的这个配置是 走的内置告警模版,我发的是自定义模版。

feiyu563 commented 2 years ago

你只需要把里面的URL改成自定义模板就行了