发布时间:2020-03-16 10:45:16编辑:admin阅读(4164)
blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。
Blackbox_exporter 应用场景
HTTP 测试
定义 Request Header 信息
判断 Http status / Http Respones Header / Http Body 内容
TCP 测试
业务组件端口状态监听
应用层协议定义与监听
ICMP 测试
主机探活机制
POST 测试
接口联通性
SSL 证书过期时间
操作系统:centos 6.9
各个版本的blackbox_exporter https://github.com/prometheus/blackbox_exporter/releases
以linux系统为例,下载编译好的二进制包,解压使用:
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.16.0/blackbox_exporter-0.16.0.linux-amd64.tar.gz tar -zxvf blackbox_exporter-0.16.0.linux-amd64.tar.gz -C /data mv /data/blackbox_exporter-0.16.0.linux-amd64 /data/blackbox_exporter
# cd /data/blackbox_exporter/ # ./blackbox_exporter --version blackbox_exporter, version 0.16.0 (branch: HEAD, revision: 991f89846ae10db22a3933356a7d196642fcb9a9) build user: root@64f600555645 build date: 20191111-16:27:24 go version: go1.13.4
nohup ./blackbox_exporter &
默认监听端口为9115
# ss -tunlp|grep 9115 tcp LISTEN 0 32768 *:9115 *:* users:(("blackbox_export",29880,3))
编辑prometheus配置文件
vi /data/prometheus/prometheus.yml
最后一行添加
- job_name: node_status metrics_path: /probe params: module: [icmp] static_configs: - targets: ['10.165.94.31'] labels: instance: node_status group: 'node' relabel_configs: - source_labels: [__address__] target_label: __param_target - target_label: __address__ replacement: 172.19.155.133:9115
注意:10.165.94.31是被监控端ip,172.19.155.133是Blackbox_exporter
- job_name: 'prometheus_port_status' metrics_path: /probe params: module: [tcp_connect] static_configs: - targets: ['172.19.155.133:8765'] labels: instance: 'port_status' group: 'tcp' relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 172.19.155.133:9115
- job_name: web_status metrics_path: /probe params: module: [http_2xx] static_configs: - targets: ['http://www.baidu.com'] labels: instance: user_status group: 'web' relabel_configs: - source_labels: [__address__] target_label: __param_target - target_label: __address__ replacement: 172.19.155.133:9115
检查配置文件是否书写正确
cd /data/prometheus ./promtool check config prometheus.yml
重启prometheus
service restart prometheus
访问 http://127.0.0.1:9090/targets 查看加入的监控信息。
确保状态为 UP
此模板为9965号模板,数据源选择Prometheus 模板下载地址 https://grafana.com/grafana/dashboards/9965
此模板需要安装饼状图插件 下载地址 https://grafana.com/grafana/plugins/grafana-piechart-panel
安装插件,重启grafana生效。
grafana-cli plugins install grafana-piechart-panel service grafana-server restart
访问 http://127.0.0.1:3000,查看数据。
本文参考链接:
https://blog.csdn.net/qq_43190337/article/details/100577728
47606
45987
36909
34470
29082
25713
24566
19715
19248
17756
5566°
6155°
5691°
5737°
6706°
5483°
5484°
5989°
5965°
7295°