栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

alertmanager告警配置

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

alertmanager告警配置

本例使用node_exporter的指标项内存占有率为例子,记录alertmanager如何配置内存占用率> 10%报警到腾讯企业邮箱。

docker-compose
version: '3.2'
services:
  prometheus:
    image: prom/prometheus:latest
    container_name: prometheus
    ports:
    - 9090:9090
    command:
    - --config.file=/etc/prometheus/prometheus.yml
    volumes:
    - ./prom/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    - ./prom/rule.yml:/etc/prometheus/rule.yml
  grafana:
    image: grafana/grafana-enterprise
    ports:
    - 3000:3000
  node_exporter:
    image: prom/node-exporter:latest
    container_name: node_exporter
    command:
      - '--path.rootfs=/host'
    network_mode: host
    pid: host
    restart: unless-stopped
    volumes:
      - '/:/host:ro,rslave'
  alertmanager:
    image: prom/alertmanager
    volumes:
    - ./alertmanager/alertmanager.yml:/etc/alertmanager/alertmanager.yml
    ports:
    - 9093:9093
prometheus配置
  • prom/prometheus.yaml
# 告警规则的配置文件
rule_files:
  - /etc/prometheus/rule.yml
# altermanager的服务地址
alerting:
  alertmanagers:
  - static_configs: 
    - targets:
      - alertmanager:9093
  • prom/rule.yml
groups:
- name: example
  rules:
  - alert: high_memory
    # 当内存占有率超过10%,持续1min,则触发告警
    expr: 100 - ((node_memory_MemAvailable_bytes{instance="192.168.10.64:9100",job="node_exporter"} * 100) / node_memory_MemTotal_bytes{instance="192.168.10.64:9100",job="node_exporter"}) > 90
    for: 1m
    labels:
      severity: page
    annotations:
      summary: spike memeory 
alertmanager配置
  • alertmanager/alertmanager.yml

如何配置腾讯企业邮箱的密码,我的这篇文章有记录- Jenkins发送email至腾讯企业邮箱 Pipeline方式

global:
  # smtp服务器地址
  smtp_smarthost: smtp.exmail.qq.com:465
  # 发送者邮箱
  smtp_from: 
  # 发送者邮箱
  smtp_auth_username: 
  # 发送者密码
  smtp_auth_password: 
  smtp_require_tls: false

route:
  group_by: ['alertname']
  group_wait: 30s
  group_interval: 5m
  repeat_interval: 1h
  receiver: 'mail'
receivers:
  - name: 'mail'
    email_configs:
     # 接收者邮箱
     - to: ''
inhibit_rules:
  - source_match:
      severity: 'critical'
    target_match:
      severity: 'warning'
    equal: ['alertname', 'dev', 'instance']

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/974462.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号