Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Combination of prometheus and alertmanager

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Alertmanager and Prometheus are two separate components. Prometheus server sends alarm to Alertmanager according to alarm rules, and then Alertmanager sends messages such as silencing, inhibition, aggregation, etc. through email, WeChat, etc.

Install and deploy alertmanager

download package

wget https://github.com/prometheus/alertmanager/releases/download/v0.20.0/alertmanager-0.20.0.linux-amd64.tar.gz

Unpack installation

tar zxvf alertmanager-0.16.0.linux-amd64.tar.gz && cd alertmanager-0.16.0.linux-amd64

Start alertmanager

./ alertmanager --config.file=alertmanager.yml

Configure prometheus to communicate with alertmanager

Modify the prometheus.yml profile

Configure communication with alertmanager

alerting: alertmanagers: - static_configs: - targets: - x.x.x.x:9093

Add alarm rule to monitor host service. Default is 1.

#Load rules once and periodically evaluate them according to the global 'evaluation_interval'.

rule_files:

"rules/*.yml"groups:- name: generals.rules rules: - alert: InstanceDown expr: up == 0 for: 1m labels: severity: error annotations: summary: "Instance {{ $labels.isinstance }} down" description: "{{ $labels.instance }} down more than 1 minutes"

Overload the configuration file kill -hup $pid or restart the prometheus service

View configured alarm rules

trigger an alarm

Alarm rule has been created, set email notification alarm, qq mailbox is displayed, qq mailbox needs to be enabled smtp,

smtp_require_tls is true by default, which needs to be modified to false, otherwise the email trigger fails, smtp_auth_password is filled in authorization ma

global: global configuration, including timeout time after alarm resolution, SMTP related configuration, API address of various channel notifications, etc.

route: Used to set the alarm distribution policy. It is a tree structure that matches from left to right in depth-first order.

receivers: Configure information about recipients of alert messages, such as email, wechat, slack, webhook, etc.

global: resolve_timeout: 5m smtp_smarthost: 'smtp.qq.com:465' smtp_from: 'xxx@qq.com' smtp_auth_username: 'xxx@qq.com' smtp_auth_password: 'xxx' #smtp_auth_secret: false smtp_require_tls: false smtp_hello: 'qq.com'route: group_by: ['alertname'] group_wait: 10s group_interval: 10s repeat_interval: 1h receiver: 'mail'receivers:- name: 'mail' email_configs: - to: 'xxx@qq.com' send_resolved: true

Trigger alarm, manually shut down, es service, receive email alarm after a few minutes

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report