溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

prometheus-operator的安裝和配置

發(fā)布時間:2020-05-25 16:24:00 來源:億速云 閱讀:251 作者:鴿子 欄目:云計(jì)算

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:生成企業(yè)微信id和secret步驟詳見前面zabbix配置微信報(bào)警
    3、創(chuàng)建微信報(bào)警模板
    vim wechat.tmpl
    {{ define "wechat.default.message" }}
    {{ range .Alerts }}
    ========start=========
    告警程序: prometheus_alert
    告警級別: {{ .Labels.serverity }}
    告警類型: {{ .Labels.alertname }}
    故障主機(jī): {{ .Labels.instance }}
    告警主題: {{ .Annotations.summary }}
    告警詳情: {{ .Annotations.description }}
    觸發(fā)時間: {{ (.StartsAt.Add 28800e9).Format "2006-01-02 15:04:05" }}
    =========end===========
    {{ end }}
    {{ end }}

4、# 先將之前的 secret 對象刪除,重新創(chuàng)建
$ 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

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI