1
Prometheus监控之Blackbox_exporter
source link: https://blog.51cto.com/u_13236892/5930363
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Prometheus监控之Blackbox_exporter
精选 原创Blackbox_exporter是Prometheus官方提供的一个exporter,可以监控HTTP,HTTPS,DNS,TCP,ICMP和gRPC等目标实例,从而实现对被监控节点进行监控和数据采集。
下载地址:
https://github.com/prometheus/blackbox_exporter
tar -xvf blackbox_exporter-0.22.0.linux-amd64.tar.gz
mv blackbox_exporter-0.22.0.linux-amd64 blackbox_exporter
/usr/local/blackbox_exporter/blackbox_exporter \
--config.file="/usr/local/blackbox_exporter/blackbox.yml" \
--web.listen-address="10.10.10.10:9115" &>blackbox_exporter.log &
启动参数有
--web.config.file="" #就可以配置TLS
--web.listen-address="10.10.10.10:9115" #指定ip和端口
设置开机自启
vi /usr/lib/systemd/system/blackbox_exporter.service
[Unit]
Description=Prometheus blackbox exporter
After=network.target
[Service]
Type=simple
User=root
Group=root
Restart=on-failure
ExecStart=/usr/local/blackbox_exporter/blackbox_exporter \
--config.file="/usr/local/blackbox_exporter/blackbox.yml" \
--web.listen-address="10.10.10.10:9115"
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart blackbox_exporter.service
下载地址:
https://github.com/prometheus/blackbox_exporter
tar -xvf blackbox_exporter-0.22.0.linux-amd64.tar.gz
mv blackbox_exporter-0.22.0.linux-amd64 blackbox_exporter
/usr/local/blackbox_exporter/blackbox_exporter \
--config.file="/usr/local/blackbox_exporter/blackbox.yml" \
--web.listen-address="10.10.10.10:9115" &>blackbox_exporter.log &
启动参数有
--web.config.file="" #就可以配置TLS
--web.listen-address="10.10.10.10:9115" #指定ip和端口
设置开机自启
vi /usr/lib/systemd/system/blackbox_exporter.service
[Unit]
Description=Prometheus blackbox exporter
After=network.target
[Service]
Type=simple
User=root
Group=root
Restart=on-failure
ExecStart=/usr/local/blackbox_exporter/blackbox_exporter \
--config.file="/usr/local/blackbox_exporter/blackbox.yml" \
--web.listen-address="10.10.10.10:9115"
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl restart blackbox_exporter.service
blackbox_exporter的监控,包括URL,ICMP,TCP等。都是先在prometheus设置监控内容,再转发到blackbox_exporter的地址,最后得出监控结果。
1、URL监控
在prometheus服务器添加url监控工作,末尾指定blackbox_exporter地址:
scrape_configs:
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
- http://baidu.com # Target to probe with http.
- https://baidu.com # Target to probe with https.
- http://example.com:8080 # Target to probe with http on port 8080.
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.10.10.10:9115 # The blackbox exporter's real hostname:port.
在blackbox_exporter服务器查看最近URL探测:
scrape_configs:
- job_name: 'blackbox'
metrics_path: /probe
params:
module: [http_2xx] # Look for a HTTP 200 response.
static_configs:
- targets:
- http://baidu.com # Target to probe with http.
- https://baidu.com # Target to probe with https.
- http://example.com:8080 # Target to probe with http on port 8080.
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: 10.10.10.10:9115 # The blackbox exporter's real hostname:port.
在blackbox_exporter服务器查看最近URL探测:
2、ICPM监控
ICMP就是Ping使用的协议,可以探测IP是否在线:
scrape_configs:
- job_name: 'ping_status'
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets:
- 192.168.10.131
- 192.168.10.132
- 192.168.10.133
labels:
instance: 'ping_status'
group: 'icmp'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip
- target_label: __address__
replacement: 10.10.10.10:9115
在blackbox_exporter服务器查看最近ICMP探测:
scrape_configs:
- job_name: 'ping_status'
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets:
- 192.168.10.131
- 192.168.10.132
- 192.168.10.133
labels:
instance: 'ping_status'
group: 'icmp'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip
- target_label: __address__
replacement: 10.10.10.10:9115
在blackbox_exporter服务器查看最近ICMP探测:
3、PORT监控
Port端口用于检测服务器端口是否开启,服务是否可用:
scrape_configs:
- job_name: 'port_status'
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: ['192.168.10.131:22','192.168.10.132:3306','192.168.10.133:8080']
labels:
instance: 'port_status'
group: 'port'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip
- target_label: __address__
replacement: 10.10.10.10:9115
在blackbox_exporter服务器查看最近Port探测:
scrape_configs:
- job_name: 'port_status'
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: ['192.168.10.131:22','192.168.10.132:3306','192.168.10.133:8080']
labels:
instance: 'port_status'
group: 'port'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip
- target_label: __address__
replacement: 10.10.10.10:9115
在blackbox_exporter服务器查看最近Port探测:
- 赞
- 收藏
- 评论
- 分享
- 举报
上一篇:Python基础之文件操作
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK