1.按照exporter
1.wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.12.0/blackbox_exporter-0.12.0.linux-amd64.tar.gz 2.tar -zxf blackbox_exporter-0.12.0.linux-amd64.tar.gz 3.mv blackbox_exporter-0.14.0.linux-amd64 /usr/local/blackbox_exporter 4../blackbox_exporter --version
2.vim /lib/systemd/system/blackbox_exporter.service -- 变成系统服务 netstat -anptu|grep 9115
[Unit] Description=blackbox_exporter After=network.target [Service] User=root Type=simple ExecStart=/usr/local/blackbox_exporter/blackbox_exporter --config.file=/usr/local/blackbox_exporter/blackbox.yml Restart=on-failure [Install] WantedBy=multi-user.target
3.监控web和端口状态
- job_name: web_status metrics_path: /probe params: module: [http_2xx] static_configs: - targets: ['http://192.168.1.49:8080/'] labels: instance: web_status group: web - targets: ['https://www.baidu.com/'] labels: instance: baidu_status group: baidu relabel_configs: - source_labels: [__address__] target_label: __param_target - target_label: __address__ replacement: 127.0.0.1:9115 - job_name: 'port_status' metrics_path: /probe params: module: [tcp_connect] static_configs: - targets: ['192.168.1.49:8080'] labels: instance: 'port_status' group: 'tcp' relabel_configs: - source_labels: [__address__] target_label: __param_target - target_label: __address__ replacement: 127.0.0.1:9115
4.dashboard -- 9665 和 7587
5.参考:https://blog.csdn.net/qq_43190337/article/details/100577728