码迷,mamicode.com
首页 > 微信 > 详细

prometheus-operator 配置企业微信报警

时间:2020-03-05 19:17:55      阅读:420      评论:0      收藏:0      [点我收藏+]

标签:ttl   opd   art   efi   http   cpu   global   receive   routes   

prometheus-operator 配置企业微信报警
1、安装prometheus-operator,具体安装步骤链接:https://www.qikqiak.com/k8s-book/docs/58.Prometheus%20Operator.html
2、修改配置文件
/root/prometheus-operator/kube-prometheus/manifests
vim alertmanager.yaml
global:
resolve_timeout: 60m
smtp_smarthost: ‘smtp.139.com:25‘
smtp_from: ‘15859527102@139.com‘
smtp_auth_username: ‘15859527102@139.com‘
smtp_auth_password: ‘x84l_asus_ak‘
smtp_hello: ‘139.com‘
smtp_require_tls: false
wechat_api_url: ‘https://qyapi.weixin.qq.com/cgi-bin/
wechat_api_secret: ‘03vUA6wHSOtfCwfi8f7DkfXc0G4V6juaYOPDRjspnGU‘
wechat_api_corp_id: ‘wwae01588e36d3f448‘
templates:

  • "*.tmpl"
    route:
    group_by: [‘job‘, ‘severity‘]
    group_wait: 30s
    group_interval: 60m
    repeat_interval: 12h
    receiver: default
    routes:
  • receiver: wechat
    match:
    alertname: CPUThrottlingHigh
    receivers:
    • name: ‘default‘
      email_configs:
  • to: ‘313841662@qq.com‘
    send_resolved: true
    • name: ‘webhook‘
      webhook_configs:
  • url: ‘http://dingtalk-hook.kube-system.svc.cluster.local:5000
    send_resolved: true
    • name: ‘wechat‘
      wechat_configs:
  • send_resolved: true
    agent_id: ‘1000002‘
    to_user: ‘@all‘
    corp_id: ‘wwae01588e36d3f448‘
    api_secret: ‘03vUA6wHSOtfCwfi8f7DkfXc0G4V6juaYOPDRjspnGU‘

    PS:生成企业微信id和secret步骤详见前面zabbix配置微信报警
    3、创建微信报警模板
    vim wechat.tmpl
    {{ define "wechat.default.message" }}
    {{ range .Alerts }}
    ========start=========
    告警程序: prometheus_alert
    告警级别: {{ .Labels.serverity }}
    告警类型: {{ .Labels.alertname }}
    故障主机: {{ .Labels.instance }}
    告警主题: {{ .Annotations.summary }}
    告警详情: {{ .Annotations.description }}
    触发时间: {{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
    =========end===========
    {{ end }}
    {{ end }}

4、# 先将之前的 secret 对象删除,重新创建
$ kubectl delete secret alertmanager-main -n monitoring
secret "alertmanager-main" deleted
kubectl create secret generic alertmanager-main --from-file=alertmanager.yaml --from-file=wechat.tmpl -n monitoring

prometheus-operator 配置企业微信报警

标签:ttl   opd   art   efi   http   cpu   global   receive   routes   

原文地址:https://blog.51cto.com/riverxyz/2475619

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!