CEPH的学习笔记(八) 安装监视器Prometheus报警系统AlertManager

CEPH的学习笔记(七) 安装监视器Prometheus报警系统AlertManager

  1. 下载AlertManager对应的安装包并解压 :
Wget https://github.com/prometheus/alertmanager/releases/download/v0.15.2/alertmanager-0.15.2.linux-amd64.tar.gz
tar zxvf alertmanager-0.15.2.linux-amd64.tar.gz
  1. 进入AlertManager的文件夹并将指定文件复制到指定目录中去:
 cd alertmanager-0.15.2.linux-amd64
cp alertmanager amtool /usr/bin/
cp alertmanager.yml /etc/prometheus/
  1. 配置 systemd 的 unit 文件:
vi /lib/systemd/system/alertmanager.service
        [Unit]
          Description=Prometheus: the alerting system
          Documentation=http://prometheus.io/docs/
          After=prometheus.service
        [Service]
          ExecStart=/usr/bin/alertmanager --config.file=/etc/prometheus/alertmanager.yml
          Restart=always
          StartLimitInterval=0
          RestartSec=10
        [Install]
          WantedBy=multi-user.target
  1. 启动AlertManager服务,并配置开机启动:
 systemctl enable alertmanager.service
 systemctl start alertmanager.service
  1. 在Prometheus 的配置文件中添加 AlertManager 的信息,并重启 Prometheus的服务:
 vi /etc/prometheus/prometheus.yml
           alerting:
              alertmanagers:
               - static_configs:
                 - targets: ["localhost:9093"]
           systemctl restart prometheus.service
  1. 注册登录企业版钉钉,在群里添加机器人,获取webhook:
    在这里插入图片描述
  2. 获取prometheus-webhook,并以容器运行:
docker pull timonwong/prometheus-webhook-dingtalk:v0.3.0
docker run -d --restart always -p 8060:8060 timonwong/prometheus-webhook-dingtalk:v0.3.0 --ding.profile="webhook1= https://oapi.dingtalk.com/robot/send?access_token=f0a0b993e82d1f2640a28951c729305ec8ff72de80a75e719f21b4c8bbe18f19"
  1. 配置 AlertManager 告警规则:
vi /etc/prometheus/alertmanager.yml
          global:
              resolve_timeout: 5m
          route:
              group_by: ['alertname']
              group_wait: 10s
              group_interval: 10s
              repeat_interval: 1h
              receiver: 'web.hook'
          receivers:
              - name: 'web.hook'
                 webhook_configs:
                  - url: 'http://localhost:8060/dingtalk/web.hook/send'
          inhibit_rules:
              - source_match:
                severity: 'critical'
              target_match:
                severity: 'warning'
              equal: ['alertname', 'dev', 'instance']
  1. 修改 /etc/prometheus/prometheus.yml,添加告警规则文件:
vi /etc/prometheus/prometheus.yml
              ......
            rule_files:
                - /etc/prometheus/rules/ceph.yaml
  1. 修改/etc/prometheus/rules/ceph.yaml,发送告警消息:
groups:
- name: ceph-rule
           rules:
           - alert: CephCapacityUsage
            expr: ceph_cluster_available_bytes / ceph_cluster_capacity_bytes * 100 > 85 
            for: 2m
            labels:
               product: ceph
             annotations:
               summary: "{{$labels.instance}}: Not enough capacity in Ceph detected"
               description: "{{$labels.instance}}: Available capacity is used up to 70% (current value is: {{ $value }}"
  1. 重启 AlertManager 和 Prometheus 服务:
systemctl restart alertmanager.service
systemctl restart prometheus.service
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值