blackbox
作者:互联网
下载并解压
https://github.com/prometheus/blackbox_exporter/releases/download/v0.21.0/blackbox_exporter-0.21.0.linux-amd64.tar.gz
tar -zxvf blackbox_exporter-0.21.0.linux-amd64.tar.gz
ln -sv /apps/blackbox_exporter-0.21.0.linux-amd64 /apps/blackbox_exporter
配置自动启动
# vim /etc/systemd/system/blackbox-exporter.service
[Unit]
Description=Prometheus Blackbox Exporter
After=network.target
[Service]
Type=simple
User=root
Group=root
ExecStart=/apps/blackbox_exporter/blackbox_exporter \
--config.file=/apps/blackbox_exporter/blackbox.yml \
--web.listen-address=:9115
[Install]
WantedBy=multi-user.target
# systemctl restart blackbox-exporter.service
# systemctl enable blackbox-exporter.service
浏览器直接访问9115端口
配置http的监控,prometheus.yml
- job_name: "http_status"
metrics_path: /probe
params:
module: [http_2xx]
static_configs:
- targets: ["http://www.xiaomi.com","http://www.baidu.com"]
labels:
instance: http_status
group: web
relabel_configs:
- source_labels: [__address__] #relabel通过将__address__(当前目标地址)写入__param_target标签来创建一个label.
target_label: __param_target #监控目标www.xiaomi.com,作为__address__的value
- source_labels: [__param_target] #监控目标
target_label: url #将监控目标与url创建一个label
- target_label: __address__
replacement: 10.211.55.20:9115
重启prometheus,查看blackbox
配置ICMP的监控,prometheus.yml
- job_name: "ping_status"
metrics_path: /probe
params:
module: [icmp]
static_configs:
- targets: ["10.211.55.21","10.211.55.22"]
labels:
instance: 'ping_status'
group: 'icmp'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip #将ip与__param_target创建一个label
- target_label: __address__
replacement: 10.211.55.20:9115
重启prometheus
端口监控,prometheus.yml
- job_name: "port_status"
metrics_path: /probe
params:
module: [tcp_connect]
static_configs:
- targets: ["10.211.55.20:6443","10.211.55.26:9100"]
labels:
instance: 'port_status'
group: 'port'
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: ip #将ip与__param_target创建一个label
- target_label: __address__
replacement: 10.211.55.20:9115
重启prometheus
grafana导入9965模板
标签:__,exporter,blackbox,target,param,label 来源: https://www.cnblogs.com/zyyang1993/p/16580635.html