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相关监控项

相关推荐
武子康几秒前
HunyuanVideo-1.5 首帧视频怎么做提示词对照?先查清 rewrite 是否生效
人工智能·后端·agent
今天早睡1 分钟前
用 Command 同时更新 State 与控制路由
后端
说实话起个名字真难啊7 分钟前
实战docker部署dify及注意点
运维·docker·容器
福建佰胜张工8 分钟前
费希尔 FIELDVUE™ DVC6200-AC 智能阀门定位器深度解析:双作用配置、核心参数与典型应用
运维·安全·自动化
智驭未来掌门人10 分钟前
Qt开发者不是只能选Qt creator
后端
小羊没烦恼!12 分钟前
分布式事务 | 使用DTM 的Saga 模式
java·linux·运维·数据库·wpf
薛定谔的悦13 分钟前
从一次逆流事故说起:储能 EMS 里的 System V 信号量与跨模块快速响应机制
后端
站大爷IP14 分钟前
Python的序列化把我坑惨了,原来json和pickle的区别这么大
后端
没事写点啥15 分钟前
WeKnora 回答溯源
前端·后端·ai编程
智驭未来掌门人15 分钟前
在 CLion 里创建 Qt 项目,真正需要想清楚的是什么
后端