Blackbox_exporter 主动监测主机与服务状态
Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集
下载地址
这里要选择自己合适的版本
下载并解压
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.18.0/blackbox_exporter-0.18.0.linux-amd64.tar.gz
tar -zxvf blackbox_exporter-0.18.0.linux-amd64.tar.gz
ARM
wget https://github.com/prometheus/blackbox_exporter/releases/download/v0.18.0/blackbox_exporter-0.18.0.linux-arm64.tar.gz
tar -zxvf blackbox_exporter-0.18.0.linux-arm64.tar.gz
配置启动文件
vim /etc/systemd/system/blackbox_exporter.service
[Unit]
Description=Prometheus Monitoring System
Documentation=Prometheus Monitoring System
[Service]
ExecStart=/opt/monitor/service/blackbox_exporter-0.18.0.linux-arm64/blackbox_exporter
--config.file=/opt/monitor/service/blackbox_exporter-0.18.0.linux-arm64/blackbox.yml
[Install]
WantedBy=multi-user.target
刷新文件
systemctl daemon-reload
启动命令
systemctl start blackbox_exporter #启动
systemctl stop blackbox_exporter #停止
systemctl restart blackbox_exporter #重启
systemctl status blackbox_exporter #查看状态
修改promethues配置文件
进入promethues文件夹
cd prometheus-2.22.1.linux-arm64/
vim prometheus.yml
static_configs:
- targets: ['192.168.*.*:1111']
labels:
hostname: '服务器名称'
group: 'tcp'
service: '服务名称'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip
regex: "(.*):(.*)"
replacement: $1
- source_labels: [__param_target]
target_label: port
regex: "(.*):(.*)"
replacement: $2
- source_labels: []
target_label: __address__
replacement: localhost:9115
重启Prometheus
systemctl restart prometheus #重启
配置Grafana
这里输入9965