为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
Docker

本系列主要介绍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


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消