1.1 下载blackbox_exporte插件
在https://github.com/prometheus/blackbox_exporter 上下载blackbox_exporte对应版本安装包,并上传到prometheus 服务器 /usr/local 目录
1.2 安装blackbox_exporte
[root@rancher local]#tar xvf blackbox_exporter-0.25.0.linux-amd64.tar.gz
[root@rancher local]#mv blackbox_exporter-0.25.0.linux-amd64 blackbox_exporter
[root@rancher local]#vim /usr/lib/systemd/system/blackbox_exporter.service
[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
[root@rancher local]#systemctl enable blackbox_exporter.service
[root@rancher local]#systemctl start blackbox_exporter.service
浏览器访问http://10.12.121.198:9115/
1.2 配置prometheus
[root@rancher prometheus]# vim /data/prometheus/prometheus.yml ###在最后2行添加 ##### blackbox站点监控 - job_name: 'blackbox' scrape_interval: 1m metrics_path: /probe params: module: [http_2xx] static_configs: - targets: - 'https://www.baidu.com' ##监控站点 relabel_configs: - source_labels: [__address__] target_label: __param_target - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 10.12.121.198:9115 - job_name: 'port_status' metrics_path: /probe params: module: [tcp_connect] static_configs: - targets: ['10.12.121.198:3306','10.12.121.198:80'] ####监控端口 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: 10.12.121.198:9115
1.3 配置prometheus 告警规则
[root@rancher rules]#vim /data/prometheus/rules/prot_ruler.yml ##配置告警规则 groups: - name: blackbox_network_stats rules: - alert: '服务探测失败' expr: probe_success == 0 for: 60s labels: severity: high alertinfo: push_blackbox_alert annotations: summary: "{{ $labels.instance }}探测失败" description: "服务探测失败,请检查业务是否正常!!!" [root@rancher rules]# systemctl reload prometheus.service ##重新加载配置
1.4 配置granfan看板
仪表盘——新建——导入
模版ID 9965
标签:__,exporter,blackbox,target,url,grafana,prometheus,local From: https://www.cnblogs.com/QIzhu/p/18190607