【问题标题】:Is it possible to configure prometheus in a docker container to scrape a target on docker host?是否可以在 docker 容器中配置 prometheus 以在 docker 主机上抓取目标?
【发布时间】:2020-02-24 17:00:58
【问题描述】:

我想在我的 docker 主机上抓取一个目标。我得到 404 或连接被拒绝。

我的问题和这里的差不多:

https://stackoverflow.com/questions/56909896/prometheus-in-docker-container-cannot-scrape-target-on-host

但接受的答案 (host.docker.internal:XXXX) 对我不起作用:/

我正在开发一个带有 linux 容器的 Docker for Windows 环境。

【问题讨论】:

  • 你能在 docker 容器内 ping host.docker.internal 吗?
  • 好主意,我测试了它并且 ping 工作正常!但是为什么它不起作用呢? ://
  • 访问_system/metrics或您配置的端点时,您是否获得指标?
  • 是的,我的指标端点位于:localhost:8080/actuator/metrics

标签: docker prometheus docker-for-windows


【解决方案1】:

已修复:

我错过了在 prometheus.yaml 中指定我的实际指标 enpoint

然后:

  - job_name: 'spring-exporter'
    static_configs:
      - targets: ['host.docker.internal:8080']

现在:

  - job_name: 'spring-exporter'
    metrics_path: '/actuator/prometheus'
    static_configs:
      - targets: ['host.docker.internal:8080']

【讨论】:

    猜你喜欢
    • 2019-11-16
    • 2015-07-05
    • 2021-11-01
    • 2019-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多