bloackbox exporter 是prometheus社区提供的黑盒监控解决方案,运行用户通过HTTP、HTTPS、DNS、TCP以及ICMP的方式对网络进行探测(主动监测主机与服务状态)。
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
mkdir /usr/local/exportermv blackbox_exporter-0.16.0.linux-amd64 /usr/local/exporter/blackbox_exporter
/usr/local/exporter/blackbox_exporter/blackbox_exporter --config.file=/usr/local/exporter/blackbox_exporter/blackbox.yml
配置文件
modules:
http_2xx:
prober: http
http_post_2xx:
prober: http
http:
method: POST
tcp_connect:
prober: tcp
pop3s_banner:
prober: tcp
tcp:
query_response:
- expect: "^+OK"
tls: true
tls_config:
insecure_skip_verify: false
ssh_banner:
prober: tcp
tcp:
query_response:
- expect: "^SSH-2.0-"
irc_banner:
prober: tcp
tcp:
query_response:
- send: "NICK prober"
- send: "USER prober prober prober :prober"
- expect: "PING :([^ ]+)"
send: "PONG ${1}"
- expect: "^:[^ ]+ 001"
icmp:
prober: icmp
[root@Prometheus exporter]# cd /usr/lib/systemd/system
# 配置blackbox的开机自启文件[root@Prometheus system]# cat blackbox_exporter.service
[Unit]Description=blackbox_exporterAfter=network.target [Service]User=prometheusGroup=prometheusWorkingDirectory=/usr/local/exporter/blackbox_exporter
ExecStart=/usr/local/exporter/blackbox_exporter/blackbox_exporter
[Install]WantedBy=multi-user.target# 启动[root@node00 system]# systemctl restart blackbox_exporter
# 查看状态[root@node00 system]# systemctl status blackbox_exporter
# 开机自启[root@node00 system]# systemctl enable blackbox_exporter
```
- job_name: 'blackbox_http_2xx'
scrape_interval: 45s
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
- https://www.baidu.com/
- 172.0.0.1:9090
- https://www.qq.com
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 114.67.116.119:9115
重启动promethus服务
展示最近监控信息
- job_name: "blackbox_http_file_test"
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
file_sd_configs:
- refresh_interval: 1m
files:
- "/usr/local/prometheus/conf/blackbox*.yml"
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 114.67.116.119:9115
[root@node00 prometheus]# cat conf/blackbox-dis.yml
- targets:
- https://www.alibaba.com
- https://www.tencent.com
- https://www.baidu.com
重启动promethus服务
解决方法
[root@Prometheus ~]# grafana-cli plugins install grafana-piechart-panel
installing grafana-piechart-panel @ 1.4.0
from: https://grafana.com/api/plugins/grafana-piechart-panel/versions/1.4.0/download
into: /var/lib/grafana/plugins
✔ Installed grafana-piechart-panel successfully Restart grafana after installing plugins . <service grafana-server restart>