继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

prometheus之docker监控与告警系列(二)

慕虎7371278
关注TA
已关注
手记 1125
粉丝 201
获赞 871

本系列主要介绍prometheus+cadvisor+alertmanager打造docker监控,主要监控指定docker容器是否挂掉

本节主要熟悉prometheus+Alertmanager的部署和基本使用

一、说明

prometheus本身并没有集成告警功能,需要配合Alertmanager使用

二、下载并安装Alertmanager

进入下载页,操作系统选择darwin

https://prometheus.io/download/

往下拉,看到alertmanager

webp

alertmanager.png

三、配置Prometheus,使其可以与Alertmanager通信

# Alertmanager配置alerting:
 alertmanagers:
 - static_configs:
   - targets: ["localhost:9093"] # 设定alertmanager和prometheus交互的接口,即alertmanager监听的ip地址和端口

四、添加prometheus.rules.yml,配置Prometheus规则,实例down掉触发alert

groups:
- name: Instances
  rules:
  - alert: InstanceDown
    expr: up == 0    for: 5s
    labels:
      severity: page    # Prometheus templates apply here in the annotation and label fields of the alert.
    annotations:
      description: '{{ $labels.instance }} of job {{ $labels.job }} has been down for more than 5 s.'
      summary: 'Instance {{ $labels.instance }} down'

为prometheus指定规则文件

rule_files:
  - 'prometheus.rules.yml'

五、编辑alertmanager.yml,配置webhook_config,即告警触发的接口调用

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:5200/auth/instanceDown'
  •   是你的告警会触发的接口调用



作者:2远
链接:https://www.jianshu.com/p/2305526bdfdd


打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP