Prometheus - Blackbox Exporter

简介: BlackBox Exporter 顾名思义就是在应用程序的外部对其进行探测,支持 HTTP、HTTPS、DNS、TCP、ICMP等方式对目标进行检测。

BlackBox Exporter 顾名思义就是在应用程序的外部对其进行探测,

支持 HTTP、HTTPS、DNS、TCP、ICMP等方式对目标进行检测。


ICMP

cat prometheus.yml

global:  scrape_interval:     15s
  evaluation_interval: 15s
scrape_configs:   - job_name: "ICMP"    metrics_path: /probe
    params:      module: [icmp]    file_sd_configs:    - refresh_interval: 10s
      files:      - targets/blackbox-exporter-icmp.yml
    relabel_configs:    - source_labels: [__address__]      target_label: __param_target
    - source_labels: [__param_target]      target_label: instance
    - target_label: __address__
      replacement: blackbox-exporter-service:9115


cat targets/blackbox-exporter-icmp.yml

- targets:   - 119.29.29.29
  - 223.5.5.5


HTTP

cat prometheus.yml

global:  scrape_interval:     15s
  evaluation_interval: 15s
scrape_configs:   - job_name: "HTTP"    metrics_path: /probe
    params:      module: [http_2xx]    file_sd_configs:    - refresh_interval: 10s
      files:      - targets/blackbox-exporter-http.yml
    relabel_configs:    - source_labels: [__address__]      target_label: __param_target
    - source_labels: [__param_target]      target_label: instance
    - target_label: __address__
      replacement: blackbox-exporter-service:9115


cat targets/blackbox-exporter-http.yml

- targets:   - https://www.baidu.com
  - https://www.google.com


TCP

cat prometheus.yml

global:  scrape_interval:     15s
  evaluation_interval: 15s
scrape_configs:   - job_name: "TCP"    metrics_path: /probe
    params:      module: [tcp]    file_sd_configs:    - refresh_interval: 10s
      files:      - targets/blackbox-exporter-tcp.yml
    relabel_configs:    - source_labels: [__address__]      target_label: __param_target
    - source_labels: [__param_target]      target_label: instance
    - target_label: __address__
      replacement: blackbox-exporter-service:9115


cat targets/blackbox-exporter-tcp.yml

- targets:   - aliyun.com:443
  - huaweicloud.com:443



标签重改& 监控原理

将 [__address__] 输出到 __param_target,是为了 Prometheus 在BlackboxExporter采集时使用对应的域名

例如 Target 中设置的是 https://www.baidu.com 则 __address__ 为 https://www.baidu.com

Prometheus 采集时则使用 http://blackbox-exporter:9115/probe?module=http_2xx&target=https://www.baidu.com

image.jpeg


由此可见,Prometheus 主动传递参数给 Blackbox 进行执行,并在 Blackbox 接口暴露出指标提供给 Prometheus 采集。

image.png


probe?module=http_2xx&target=https://www.google.com

http_2xx 为模块名称

https://www.google.com 为执行监控的目标


Grafana

Dashboard ID: 13659

image.jpeg


Dashboard ID: 9965

需要额外安装饼图插件支持: grafana-cli plugins install grafana-piechart-panel

image.jpeg


Trouble

报错: 通过 IPv6 连接不到目标

解决方案: 修改对应模块的IP协议为 IPv4

modules:  http_2xx:    prober: http
    http: preferred_ip_protocol: "ip4"  icmp:    prober: icmp
    icmp: preferred_ip_protocol: "ip4"  tcp:    prober: tcp
    tcp: preferred_ip_protocol: "ip4"

Refer: https://github.com/prometheus/blackbox_exporter/blob/master/CONFIGURATION.md



Debug

probe?target=119.29.29.29&module=icmp&debug=true

通过传递 debug=true 参数可以进行 Probe 过程中的调试

image.png


目录
相关文章
|
4月前
|
消息中间件 Prometheus 监控
Prometheus实战篇:什么是Exporter
所有可以向Prometheus提供监控样本数据的程序都可以被称为一个Exporter.而Exporter的一个实例称为target,如图下所示, Prometheus通过轮询的方式定期从这些target中获取样本数据
|
8月前
|
Prometheus Cloud Native Linux
Prometheus(二)之Node Exporter采集Linux主机数据
Prometheus(二)之Node Exporter采集Linux主机数据
164 0
|
9月前
|
JSON Prometheus 监控
使用Exporter为Prometheus添加监控对象(持续更新ing)
使用Exporter为Prometheus添加监控对象(持续更新ing)
197 0
|
数据采集 Prometheus 监控
Prometheus 基于Python Django实现Prometheus Exporter
Prometheus 基于Python Django实现Prometheus Exporter
198 0
|
存储 Prometheus 监控
Exporter + Prometheus + Grafana进行监控
Exporter + Prometheus + Grafana进行监控
304 0
Exporter + Prometheus + Grafana进行监控
|
Prometheus 监控 Cloud Native
Prometheus 部署 Black Exporter 黑盒监控 DNS-TCP-ICMP
建议软件包安装,二进制安装请自行解决配置问题,docker 安装需考虑网络问题。
769 0
|
消息中间件 存储 Prometheus
基于 RocketMQ Prometheus Exporter 打造定制化 DevOps 平台
本文将对 RocketMQ-Exporter 的设计实现做一个简单的介绍,读者可通过本文了解到 RocketMQ-Exporter 的实现过程,以及通过 RocketMQ-Exporter 来搭建自己的 RocketMQ 监控系统。RocketMQ 在线可交互教程现已登录知行动手实验室,PC 端登录 start.aliyun.com 即可直达。
338 0
基于 RocketMQ Prometheus Exporter 打造定制化 DevOps 平台
|
Prometheus 监控 Cloud Native
基于prometheus 实现exporter新增监控指标
基于prometheus 实现exporter新增监控指标
383 0
|
消息中间件 存储 Prometheus
基于RocketMQ Prometheus Exporter 打造定制化DevOps平台
本文将对RocketMQ-Exporter的设计实现做一个简单的介绍,读者可以通过本文了解到RocketMQ-Exporter的实现过程,以及通过RocketMQ-Exporter来搭建自己的RocketMQ监控系统。该项目的git 地址https://github.com/apache/rocketmq-exporter
基于RocketMQ Prometheus Exporter 打造定制化DevOps平台