Prometheus blackbox-exporter ICMP ping 监控配置所有目标都显示出来

Posted

技术标签:

【中文标题】Prometheus blackbox-exporter ICMP ping 监控配置所有目标都显示出来【英文标题】:Prometheus blackbox-exporter ICMP ping monitoring configurations all targets are showing up 【发布时间】:2020-06-11 10:08:01 【问题描述】:

我正在使用 Prometheus Blackbox-exporter ICMP 设置监控 N 个系统的 UP/Down 状态。

blackbox-exporter 配置:

modules:
  icmp:                                                                                                                                                                                       
    prober: icmp                                                                                                                                                                              
    timeout: 5s                                                                                                                                                                               
    icmp:                                                                                                                                                                                     

      preferred_ip_protocol: "ip4"

Prometheus 配置:

  global:                                                                                                                                                                                       
  scrape_interval:     15s                                                                                                                                                                                                  
  external_labels:                                                                          
    monitor: 'codelab-monitor'                                                                                                                                                                
scrape_configs:                                                                                                                                                                               
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['prometheus:9090']
  - job_name: 'blackbox'                                                                                                                                                                      
    metrics_path: /probe                                                                                                                                                                      
    params:                                                                                                                                                                                   
      module: [icmp]

    static_configs:                                                                                                                                                                           
      - targets: ['192.168.1.29', '987.234.121.1']                                                                                                                                                            
        labels:                                                                                                                                                                               
          group: 'Build'                                                                                                                                                                   
      - targets: ['161.92.248.21', '161.92.3.185', '10.10.4.18']                                           
        labels:                                                                                                                                                                               
          group: 'RND' 
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: blackboxexporter:9115

blackbox-exporter 探测结果准确且看起来不错 注意:结果显示无法访问的目标失败,这看起来很好

Recent Probes
Module  Target         Result   Debug
icmp    192.168.1.29    Failure Logs
icmp    192.168.3.185   Failure Logs
icmp    161.92.248.21   Success Logs
icmp    192.168.4.185   Failure Logs
icmp    987.234.121.1   Failure Logs
icmp    192.168.1.29    Failure Logs
icmp    192.168.3.185   Failure Logs
icmp    161.92.248.21   Success Logs

Prometheus 结果不准确。这显示所有目标都已启动 注意:预期结果是失败目标应该以 0/1 显示

blackbox (5/5 up) 
Endpoint    State   Labels  Last Scrape Scrape Duration Error
http://blackboxexporter:9115/probe
module="icmp" target="161.92.248.21"    UP  group="RND" instance="161.92.248.21" job="blackbox" 1.43s ago   1.522ms 
http://blackboxexporter:9115/probe
module="icmp" target="192.168.1.29" UP  group="Build" instance="192.168.1.29" job="blackbox"    5.548s ago  1.501s  
http://blackboxexporter:9115/probe
module="icmp" target="192.168.3.185"    UP  group="RND" instance="192.168.3.185" job="blackbox" 1.944s ago  1.501s  
http://blackboxexporter:9115/probe
module="icmp" target="192.168.4.185"    UP  group="RND" instance="192.168.4.185" job="blackbox" 3.09s ago   1.501s  
http://blackboxexporter:9115/probe
module="icmp" target="987.234.121.1"    UP  group="Build" instance="987.234.121.1" job="blackbox"   2.796s ago  1.506ms   

【问题讨论】:

【参考方案1】:

我相信在 Prometheus 中查询 probe_success 指标会给你预期的结果。

在使用 blackbox-exporter 时,我们通常会根据该指标创建基本的“向上/向下”警报。

【讨论】:

谢谢@nsmeds。是的,我知道了,probe_success 查询就是查询。

以上是关于Prometheus blackbox-exporter ICMP ping 监控配置所有目标都显示出来的主要内容,如果未能解决你的问题,请参考以下文章

grafana和prometheus系列六:prometheus默认存储

2019最新 prometheus视频教程 prometheus监控视频 prometheus入门与实践教程

2019最新 prometheus视频教程 prometheus监控视频 prometheus入门与实践教程

Prometheus简介

Prometheus学习系列之Prometheus 联盟迁移

Prometheus 运维监控