blackbox_exporter是Prometheus 官方提供的 exporter 之一,可以提供 http、dns、tcp、icmp 的监控数据采集。
系统 | 版本 |
---|---|
CentOS | 7.6.1810 (Core) |
CPU/内存 | 4核、8G |
blackbox_exporter | 0.22.0 |
下载这个 blackbox_exporter-0.22.0.linux-amd64.tar.gz
[root@A bag]# tar xf blackbox_exporter-0.22.0.linux-amd64.tar.gz
[root@A bag]# mv blackbox_exporter-0.22.0.linux-amd64 ../blackbox_exporter
[root@A bag]# useradd -M -s /sbin/nologin prometheus
[root@A bag]# chown -R prometheus:prometheus /data/blackbox_exporter
/data/blackbox_exporter/blackbox.yml
modules:
http_2xx:
prober: http
http_post_2xx:
prober: http
http:
method: POST
tcp_connect:
prober: tcp
pop3s_banner:
prober: tcp
tcp:
query_response:
- expect: "^+OK"
tls: true
tls_config:
insecure_skip_verify: false
grpc:
prober: grpc
grpc:
tls: true
preferred_ip_protocol: "ip4"
grpc_plain:
prober: grpc
grpc:
tls: false
service: "service1"
ssh_banner:
prober: tcp
tcp:
query_response:
- expect: "^SSH-2.0-"
- send: "SSH-2.0-blackbox-ssh-check"
irc_banner:
prober: tcp
tcp:
query_response:
- send: "NICK prober"
- send: "USER prober prober prober :prober"
- expect: "PING :([^ ]+)"
send: "PONG ${1}"
- expect: "^:[^ ]+ 001"
icmp:
prober: icmp
icmp_ttl5:
prober: icmp
timeout: 5s
icmp:
ttl: 5
cat <<EOF>> /usr/lib/systemd/system/blackbox_exporter.service
Unit]
Description=blackbox_exporter
After=network.target
[Service]
User=prometheus
Group=prometheus
ExecStart=/data/blackbox_exporter/blackbox_exporter --config.file=/data/blackbox_exporter/blackbox.yml
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable blackbox_exporter --now
systemctl status blackbox_exporter
systemctl stop blackbox_exporter
ID: 7362
参考
scrape_configs:
- job_name: 'tcp_port_status'
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: ['192.168.1.10:3306','192.168.1.20:3307','192.168.1.30:3308']
labels:
instance: '192.168.1.10'
tags: '自定义名字'
- targets: ['192.168.1.40:2222']
labels:
instance: '192.168.1.40'
tags: '自定义名字'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.1.10:9115
- job_name: 'web_port_status'
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: ['192.168.1.10:8080']
labels:
instance: '192.168.1.10'
tags: '自定义名字'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 192.168.1.10:9115
以上是centos上边部署blackbox_exporter监控端口的方法,有问题联系博主,后续也有其他插件