美文网首页
Prometheus中Alertmanager的高可靠部署

Prometheus中Alertmanager的高可靠部署

作者: show16 | 来源:发表于2019-02-21 20:23 被阅读25次

    一 简介

    Prometheus和Alertmanager之间的通信架构如下图:Prometheus发送报警通知给Alertmanager,Alertmanager处理后发送报警或恢复通知给Email,Webhook等后端。

    虽然Prometheus以及Alertmanager的通知模块都实现了比如失败重试,超时恢复等机制,但由于报警以及恢复通知都是内存队列存储,所以如果各个模块不做可靠性部署的话,当prometheus,alertmanager,接收通知的后端节点中的一个或多个挂掉后,都可能导致报警或恢复通知丢失。

    报警通知功能是监控中的一个很重要的功能,所以针对报警通知的可靠性部署也是非常重要的。以下我将采用Prometheus官方推荐的方法来实现针对Alertmanager的可靠性部署。

    Prometheus技术架构图

    二 部署方案

    参考文章:
    high-availability-prometheus-alerting-and-notification

    alertmanager的可靠性部署架构图

    三 部署实践

    以下是在单台windows机器上进行的人肉Ops,具体生产环节还请采用更好的方法~
    ① alertmanager配置文件(2台配置相同):

    global:
      resolve_timeout: 5m
    
    route:
      group_by: ['alertname']
      group_wait: 1s
      group_interval: 1s
      repeat_interval: 5m
      receiver: 'web.hook'
    receivers:
    - name: 'web.hook'
      webhook_configs:
      - url: 'http://localhost:9002/openapi/alert/notice'  ##实验使用的通知方式,请自行替换
    

    ② 启动由2个节点构成的Alertmanager集群:

    alertmanager.exe --web.listen-address=":9095" --cluster.listen-address="localhost:9096" --cluster.peer="localhost:9094" --cluster.peer="localhost:9096" --log.level=debug
    
    alertmanager.exe --web.listen-address=":9093" --cluster.listen-address="localhost:9094" --cluster.peer="localhost:9094" --cluster.peer="localhost:9096" --log.level=debug
    

    ③ Prometheus配置(2台配置相同):

    groups:
    - name: num_temp
      rules:
      - alert: num_temp_check
        expr: num_temp_celsius{instance="localhost:8080",job="prometheus"}>10 ##实验使用的规则,请自行替换
        for: 30s
        labels:
          severity: warn
        annotations:
          summary: temp is warn
     
      - alert: num_temp_serious
        expr: num_temp_celsius{instance="localhost:8080",job="prometheus"}>15
        for: 30s
        labels:
          severity: serious
        annotations:
          summary: temp is seriously 
    
      - alert: num_temp_disaster
        expr: num_temp_celsius{instance="localhost:8080",job="prometheus"}>19
        for: 30s
        labels:
          severity: disaster
        annotations:
          summary: temp is disaster
    

    ③ 启动Prometheus:

    prometheus.exe  --log.level=debug
    
    prometheus.exe  --web.listen-address=":9092" --log.level=debug
    

    相关文章

      网友评论

          本文标题:Prometheus中Alertmanager的高可靠部署

          本文链接:https://www.haomeiwen.com/subject/llgdyqtx.html