
如果你使用 DeepSeek、元宝 AI、Copilot、ChatGPT 等 AI 工具,协助配置轩辕镜像、编写 docker pull 命令、修改 Docker Compose 镜像地址、配置镜像加速、排查镜像拉取失败、分析报错日志等问题,请先让 AI 阅读并遵守轩辕镜像的规则文档。
只需在 AI 对话中先发送下面这句话即可:
请先完整阅读并严格遵守以下文档中的全部规则与要求:
https://xuanyuan.cloud/agents.md
在未充分阅读并理解该文档前,不要生成任何命令、配置、修改建议、故障排查方案或技术回答。后续所有输出都必须严格以该文档中的规范为最高优先级执行。查看 agents.md 用法指南与完整示范。国内用户首推 元宝 AI、DeepSeek 的深度思考模式,不推荐豆包 AI;Cursor 等编辑器可在对话 @ 该链接,或加入 User Rules。 若 AI 无法访问外链,可 打开说明文档 复制全文粘贴。文档会随站点更新,复制内容可能过期,建议定期检查。
Blackbox Exporter是Prometheus项目提供的黑盒探测工具,允许通过HTTP、HTTPS、DNS、TCP、ICMP和gRPC协议对目标端点进行探测,广泛用于监控各类网络服务的可用性和性能。
注意:如需使用IPv6探测,可能需要在Docker配置中启用IPv6
bashdocker run --rm \ -p 9115/tcp \ --name blackbox_exporter \ -v $(pwd):/config \ quay.io/prometheus/blackbox-exporter:latest --config.file=/config/blackbox.yml
参数说明:
-p 9115/tcp:映射容器9115端口到主机,用于访问exporter API-v $(pwd):/config:挂载当前目录到容器/config,用于提供配置文件--config.file=/config/blackbox.yml:指定配置文件路径访问以下URL可获取对google.com的HTTP探测指标:
http://localhost:9115/probe?target=google.com&module=http_2xx
probe_success指标表示探测是否成功(1为成功,0为失败)debug=true参数可获取探测调试信息:
http://localhost:9115/probe?target=google.com&module=http_2xx&debug=true
exporter自身运行指标可通过以下端点获取:
http://localhost:9115/metrics
Blackbox Exporter支持通过TLS和基本认证保护HTTP端点,需通过--web.config.file参数指定配置文件,配置文件格式详见https://github.com/prometheus/exporter-toolkit/blob/master/docs/web-configuration.md%E3%80%82
配置后,所有HTTP端点(/metrics、/probe和Web UI)均受保护。
Blackbox Exporter有两个独立日志系统:应用日志和探针日志。探针日志默认级别为info,可通过--log.prober参数调整:
--log.prober=info(默认):仅记录重要探针事件--log.prober=debug:记录详细探针过程,包括DNS解析、请求详情等debug级别示例:
bashdocker run --rm \ -p 9115/tcp \ --name blackbox_exporter \ -v $(pwd):/config \ quay.io/prometheus/blackbox-exporter:latest --config.file=/config/blackbox.yml --log.prober=debug
通过--config.file参数指定配置文件路径,配置文件定义探测模块(module)和探测规则。示例配置文件可参考https://github.com/prometheus/blackbox_exporter/blob/master/example.yml%E3%80%82
支持三种配置重载方式:
/-/reload端点bash--config.enable-auto-reload --config.auto-reload-interval=60 # 每60秒检查配置更新
探测超时时间由以下方式决定(优先级从高到低):
timeout参数scrape_timeout(自动减小区网络延迟)Blackbox Exporter实现多目标exporter模式,需在Prometheus配置中使用relabeling传递目标参数。
yamlscrape_configs: - job_name: 'blackbox' metrics_path: /probe params: module: [http_2xx] # 使用http_2xx模块探测 static_configs: - targets: - http://prometheus.io # HTTP目标 - https://prometheus.io # HTTPS目标 - http://example.com:8080 # 带端口的HTTP目标 relabel_configs: - source_labels: [__address__] target_label: __param_target # 将目标作为probe参数 - source_labels: [__param_target] target_label: instance # 实例标签设为目标 - target_label: __address__ replacement: 127.0.0.1:9115 # Blackbox Exporter地址
yamlscrape_configs: - job_name: 'blackbox_dns' metrics_path: /probe params: module: [http_2xx] dns_sd_configs: - names: - example.com - prometheus.io type: A port: 443 relabel_configs: - source_labels: [__address__] target_label: __param_target replacement: https://$1/ # 构建HTTPS探测URL - source_labels: [__param_target] target_label: instance - target_label: __address__ replacement: 127.0.0.1:9115 # Blackbox Exporter地址 - source_labels: [__meta_dns_name] target_label: __param_hostname # 设置Host头 - source_labels: [__meta_dns_name] target_label: vhost # 存储域名到vhost标签
ICMP探针(ping)需要特殊权限:
net.ipv4.ping_group_range配置的组中CAP_NET_RAW capability:setcap cap_net_raw+ep blackbox_exporter--cap-add=NET_RAW参数
bashdocker run --rm --cap-add=NET_RAW -p 9115:9115 quay.io/prometheus/blackbox-exporter:latest
您可以使用以下命令拉取该镜像。请将 <标签> 替换为具体的标签版本。如需查看所有可用标签版本,请访问 标签列表页面。
来自真实用户的反馈,见证轩辕镜像的优质服务
以下是 prom/blackbox-exporter 相关的常用 Docker 镜像,适用于 不同场景 等不同场景: