下载安装blackbox
代码语言:javascript
复制https://github.com/prometheus/blackbox_exporter/releases
配置prometheus.yml
代码语言:javascript
复制 - job_name: 'black_exporter_tcp'
scrape_interval: 30s
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets:
- 172.16.20.213:12800
labels:
alias: skywalking
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 172.16.20.150:9115
创建启动脚本
代码语言:javascript
复制vim /usr/lib/systemd/system/blackbox_exporter.service
[Unit]
Documentation=https://github.com/prometheus/blackbox_exporter
After=network.target
[Service]
User=root
ExecStart=/usr/local/bin/blackbox_exporter --config.file=/etc/prometheus/blackbox.yml
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target
添加告警通知
代码语言:javascript
复制vim /etc/prometheus/rules/blackbox.yml
groups:
- name: blackbox_exporter_tcp
rules:
- alert: BlackboxEndpointDown
expr: probe_success == 0
for: 1m
labels:
severity: warning
annotations:
summary: "BlackboxEndpoint {{ $labels.instance }} down"
重启prometheus