Blackbox-Exporter添加Basicauth(非必要)
FROM prom/blackbox-exporter:v0.25.0
COPY password.yml /etc/blackbox_exporter/
EXPOSE 9115
ENTRYPOINT [ "/bin/blackbox_exporter" ]
CMD [ "--config.file=/etc/blackbox_exporter/config.yml","--web.config.file=/etc/blackbox_exporter/password.yml" ]
##构建镜像
docker build -t blackbox-exporter-s:v0.25.0 .
##运行容器
docker run -dit --network=host -v blackbox_exporter:/etc/blackbox_exporter/ --restart=always --name=blackbox-exporter-s blackbox-exporter-s:v0.25.0
调整配置
#1、默认不需要对Blackbox的配置文件进行修改
#2、监控目标端口,修改prometheus.yml即可。以下为示例:
- job_name: '端口监控'
basic_auth:
username: abc
password: 123
metrics_path: /probe
params:
module: [tcp_connect] ## 和Blackbox配置文件中的模块名对应
static_configs:
- targets: [10.1.1.101:9090]
labels: ## 标签可按照实际情况添加
name: 'prometheus '
ip: 10.1.1.101
port:9090
- targets: [10.1.1.101:3000]
labels:
name: 'grafana'
ip: 10.1.1.101
port:3000
- targets: [10.1.1.101:9093]
labels:
name: 'alertmanager'
ip: 10.1.1.101
port:9093
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance # 把target重赋一个label,value为任意
- target_label: __address__
replacement: 10.1.1.101:9115 # 修改为blackbox-exporter的地址
标签:10.1,__,Exporter,blackbox,target,1.101,Prometheus,exporter,BlackBox
From: https://www.cnblogs.com/light-year/p/18299648