【问题标题】:Prometheus: Error: 404, response body: 404 page not found when trying to push metrics using PushGatewayPrometheus:错误:404,响应正文:尝试使用 PushGateway 推送指标时找不到 404 页面
【发布时间】:2020-08-21 14:08:27
【问题描述】:

我正在尝试使用 PushGateway 推送指标,但在推送指标时出现以下错误:

java.io.IOException: Response code from http://169.41.73.106:30000/metrics/job/pushgateway was 404, response body: 404 page not found

at io.prometheus.client.exporter.PushGateway.doRequest(PushGateway.java:325)

at io.prometheus.client.exporter.PushGateway.pushAdd(PushGateway.java:160)

at com.test.promtheus.App.main(App.java:37)

直到 http://169.41.73.106:30000/metrics 的 URL 工作正常,但是当我尝试 /metrics/job 使用提到的任何抓取作业名称时,我得到 404。有人可以帮忙吗?

【问题讨论】:

  • 我预计错误消息来自propetheus API。您是否尝试过从程序运行的服务器上卷曲?这可能是接口绑定的问题。

标签: prometheus prometheus-java


【解决方案1】:

https://github.com/Prometheus/pushgateway 我认为您需要先设置 pushgateway,然后将 pushgateway 的地址+端口(localhost:9091)添加到 prometheus 配置文件,然后运行您 pushgateway 客户端再次发送指标,它适用于我

【讨论】:

    【解决方案2】:

    如果你们在构建 POC 或配置新环境的过程中看到 404 响应,那么你们可能犯了和我一样的错误。我使用的是 Prometheus Web 服务器 URL,而不是推送网关 Web 服务器 URL。这是两个不同的 Web 服务器。它们可能在同一台主机上运行,​​但在不同的端口上或位于完全不同的服务器上。 在可能的情况下,这是两个不同的域,如下所示:https://prometheus.company.comhttps://prometheus-pushgateway.company.com

    http://169.41.73.106:30000/metrics 的 URL 工作正常

    当您打开推送网关时,/mertics 端点上的 GET 应该不能正常工作,但可以在 prometheus Web 服务器上工作。使用 /mertics 端点查找您使用的服务器。

    【讨论】:

      【解决方案3】:

      发布我的答案以防万一。如果有人遇到相同的错误并且以上 2 个答案无济于事。

      如果您发布指标的 Pushgateway URL 没有“job”字样(Prometheus 抓取时将使用的关键字),您可能会收到相同的 404 错误。

      我收到了这个 404 错误,因为我的网址类似于:

      http://<pushgatewayip_other_than_prometheus_ip>:9091/metrics/custom_label/label_value
      

      我能够通过使用 url 解决问题:

      http://<pushgatewayip_other_than_prometheus_ip>:9091/metrics/job/pushgateway/custom_label/label_value
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-02-16
        • 2012-12-29
        相关资源
        最近更新 更多