You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Prometheus配置insecure_skip_verify后仍报TLS证书错误求助

问题原因及解决办法

核心原因

日志里的172.19.0.1是Docker网桥的默认网关IP,这个错误并非来自你配置的业务scrape任务,而是源于Prometheus默认的自身监控scrape任务或自动服务发现生成的额外scrape任务——这些任务的TLS验证规则未被正确配置为跳过证书校验。你仅在业务scrape job中设置了insecure_skip_verify: true,但其他默认/自动生成的job仍在执行严格的证书验证,而这些端点的证书不在你的根CA信任链内,因此触发了冗余错误日志。

具体排查与解决步骤

1. 定位错误对应的scrape job

查看完整日志条目,找到错误关联的job标签,比如类似如下日志行:

level=error ts=... caller=scrape.go... msg="TLS handshake error" target=http://172.19.0.1:xxx/metrics job="prometheus" ...

若job名称为prometheus,则说明是Prometheus默认的自身监控任务出了问题。

2. 修正Prometheus自身scrape job的TLS配置

打开prometheus.yml,找到名为prometheus的scrape job(默认配置自带该任务),在其tls_config中添加insecure_skip_verify: true:

scrape_configs:
  # 默认自身监控job
  - job_name: "prometheus"
    static_configs:
      - targets: ["localhost:9090"]
    # 添加或修改tls_config
    tls_config:
      insecure_skip_verify: true

如果你给Prometheus自身的web端点启用了TLS,也可以直接将根CA证书路径配置到该job中,替代跳过验证:

tls_config:
  ca_file: /path/to/your/rootCA.crt

3. 检查并处理Docker服务发现(若启用)

如果你的Prometheus配置了docker_sd_configs(Docker服务发现),它会自动扫描Docker网络内的所有端点,包括网桥网关的潜在端口。此时可通过两种方式处理:

  • 在relabel_configs中过滤掉172.19.0.1目标:
relabel_configs:
  - source_labels: [__address__]
    regex: 172.19.0.1:.*
    action: drop
  • 给Docker服务发现对应的scrape job添加insecure_skip_verify: true。

4. 验证配置并重启Prometheus

修改配置后,先验证文件合法性:

docker exec <prometheus-container-name> promtool check config /etc/prometheus/prometheus.yml

验证通过后重启容器:

docker restart <prometheus-container-name>

额外说明

业务运行正常证明你的业务scrape job配置已生效,日志冗余完全由未正确配置的额外scrape任务导致,按上述步骤处理即可消除错误日志。

内容的提问来源于stack exchange,提问作者zappee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 14:55:00