Get the App
SLTechnology News&Howtos  ›  Servers  › 

Installation and configuration of prometheus-operator

Shulou Source: shulou.com Published: 2022-06-03 05:47:29 10月03日 Update

1. Install prometheus-operator. Link to specific installation steps: https://www.qikqiak.com/k8s-book/docs/58.Prometheus%20Operator.html

2. Modify the configuration file

/ 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: 'x84lingual asussimak'

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: truename: 'webhook'

Webhook_configs:url: 'http://dingtalk-hook.kube-system.svc.cluster.local:5000'

Send_resolved: truename: 'wechat'

Wechat_configs:

Send_resolved: true

Agent_id: '1000002'

To_user:'@ all'

Corp_id: 'wwae01588e36d3f448'

Api_secret: '03vUA6wHSOtfCwfi8f7DkfXc0G4V6juaYOPDRjspnGU'

PS: for more information on generating WeCom id and secret, please see the previous zabbix configuration Wechat alarm.

3. Create Wechat alarm template

Vim wechat.tmpl

{{define "wechat.default.message"}}

{{range .Alerts}}

= start=

Alarm program: prometheus_alert

Alarm level: {{.Labels.serverity}}

Alarm type: {{.Labels.alertname}}

Failed host: {{.Labels.instance}}

Alarm topic: {{.Annotations.summary}}

Alarm details: {{.Annotations.description}}

Trigger time: {{(.StartsAt.Add 28800e9) .Format "2006-01-02 15:04:05"}}

= end=

{{end}}

{{end}}

4. # first delete the previous secret object and recreate it

$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

Tags: Configuration steps alarm host subject enterprise object fault file time template program type level details link first generate Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB Docker Shulou Tech Info Shulou Information