blackbox_exporter介绍
Blackbox Exporter是Prometheus社区提供的官方黑盒监控解决方案,其允许用户通过:HTTP、HTTPS、DNS、TCP以及ICMP的方式对网络进行探测。
1、安装部署
cd /usr/loacl tar -xvf blackbox_exporter-0.14.0.linux-amd64.tar.gz ln -s /usr/local/blackbox_exporter-0.14.0.linux-amd64 /usr/local/blackbox_exporter cd /usr/local/blackbox_exporter;mkdir bin conf mv blackbox_exporter ./bin mv blackbox.yml ./conf
2、配置
modules: http_2xx_check: prober: http timeout: 5s http: valid_status_codes: [] method: GET icmp_check: prober: icmp timeout: 5s icmp: preferred_ip_protocol: "ip4" dns_examplecom_check: prober: dns dns: preferred_ip_protocol: "ip4" query_name: "www.cnblogs.com"
3、启动
nohup /usr/local/blackbox_exporter/bin/blackbox_exporter --config.file=/usr/local/blackbox_exporter/conf/blackbox.yml > blackbox_exporter.out 2>&1 &
4、prometheus.yml 配置
- job_name: 'http_probe' metrics_path: /probe params: module: [http_2xx_check] file_sd_configs: - files: - 'targets/probes/*.json' refresh_interval: 5m relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 192.168.31.82:9115
备注:
- 第一个relabel通过将__address__标签(当前目标地址)写入__param_target标签来创建一个参数。
- 第二个relabel将__param_target标签写为实例标签。
- 最后一个使用我们的主机名(和端口)重新标记__address__标签。
5、targets/probes/probes.json配置
[{ "targets": [ "http://www.cnblogs.com" ] }]
6、重载
curl -X POST http://127.0.0.1:9090/-/reload