Prometheus blackbox exporter实现ICMP监控

Prometheus配置文件配置

yaml 复制代码
# my global config
global:
  scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
  # scrape_timeout is set to the global default (10s).

# Alertmanager configuration
alerting:
  alertmanagers:
    - static_configs:
        - targets:
          # - alertmanager:9093

# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
  # - "first_rules.yml"
  # - "second_rules.yml"

# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
  - job_name: "prometheus"

    # metrics_path defaults to '/metrics'
    # scheme defaults to 'http'.

    static_configs:
      - targets: ["localhost:9090"]
  - job_name: "node-exporter"
    static_configs:
      - targets: ["192.168.202.221:9100","192.168.202.222:9100","192.168.202.223:9100","192.168.202.224:9100"]
  - job_name: "http_status"
    metrics_path: /probe
    params:
      module: [http_2xx]
    static_configs:
      - targets: ["http://www.bing.com","https://www.baidu.com","https://www.jd.com"]
        labels:
          instance: http_status
          group: web
    relabel_configs:
      - source_labels: [__address__]  # relabel通过将__address__(当前目标地址)写入__param_target标签来创建一个label
        target_label: __param_target  # 监控目标http://www.bing.com,值为__address__的值
      - source_labels: [__param_target]  # 监控目标
        target_label: url              # 将监控目标与url创建一个label,此处的url值为__param_target里面的值
      - target_label: __address__
        replacement: 192.168.202.221:9115  # 写blackbox地址
  - job_name: "ping_status"
    metrics_path: /probe
    params: 
      module: [icmp]  # ping检查使用的模块
    static_configs:
       # targets指定检查的目标
      - targets: ["192.168.202.221","192.168.202.222","192.168.202.223","192.168.202.224"]
        labels:
          instance: "ping_status"  # 添加标签instance
          group: "icmp"  # 添加标签group
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: ip
      - target_label: __address__
        replacement: 192.168.202.221:9115 

查看结果

blackbox exporter会显示icmp相关监控项

相关推荐
卷无止境27 分钟前
除了开发api,FastAPI其实也可以配合jinja2模板写页面
后端·python·fastapi
HiDev_27 分钟前
【非标自动化】2、认识元器件(高速计数模块)
运维·自动化
newerp34 分钟前
Redis 操作与缓存策略
后端·程序员·go
newerp37 分钟前
GORM ORM 基础
后端·程序员·go
小岛前端43 分钟前
AI Skills 已经封神,但新的问题却越来越严重!
前端·后端·github
拖孩1 小时前
一个人 + AI 做的小程序,上线 15 天赚了 10 块 5
前端·后端·微信小程序
newerp1 小时前
CRUD 操作与预处理语句
后端·程序员·go
小张同学a.1 小时前
MooseFS 分布式存储实战指南:部署、运维与 Pacemaker+SBD 高可用落地
linux·运维·分布式·pacemaker·moosefs·sbd
wei_shuo1 小时前
KES 数据同步与ETL实战:数据集成、转换与实时同步方案
后端
乒乓狂魔14786739970001 小时前
LangGraph:用一张图,编排一群 AI 助手
后端