Prometheus之Blackbox监控
部署Blackbox
1
| 下载地址 https://github.com/prometheus/blackbox_exporter
|
这里使用amd64架构的软件包,根据自己设备架构选择
右键复制链接地址
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| 下载软件包 wget https:
解压 tar xf blackbox_exporter-0.25.0.linux-amd64.tar.gz
mv blackbox_exporter-0.25.0.linux-amd64/blackbox_exporter /usr/local/bin/blackbox_exporter
mv blackbox_exporter-0.25.0.linux-amd64 /usr/local/blackbox_exporter
注册服务启动 cat > /usr/lib/systemd/system/blackbox.service << EOF [Unit] Description=Prometheus Blackbox Exporter After=network.target
[Service] Type=simple User=root Group=root ExecStart=/usr/local/bin/blackbox_exporter --config.file=/usr/local/blackbox_exporter/blackbox.yml Restart=on-failure
[Install] WantedBy=multi-user.target EOF
启动服务 systemctl start blackbox.service
查看启动状态 systemctl status blackbox.service
配置开机自启 systemctl enable blackbox.service
|
配置Prometheus采集信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| - job_name: "百度" scrape_interval: 1m metrics_path: /probe params: module: [http_2xx] static_configs: - targets: ['https://www.baidu.com/'] labels: blackbox: '测试百度' relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 172.16.0.3:9115 - job_name: "Google" scrape_interval: 1m metrics_path: /probe params: module: [http_2xx] static_configs: - targets: ['https://www.google.com/'] labels: blackbox: '测试Google' relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 172.16.0.3:9115
|
1 2
| 重载prometheus配置 docker restart prometheus
|
配置Grafnana
导入模版ID 9965
效果如下
完成
能看到连通性、状态、访问耗时、1小时可用率、证书到期时间 还是不错的