Prometheus: Error: 404, response body: 404 page not found when trying to push metrics using PushGateway

Prometheus: Error: 404, response body: 404 page not found when trying to push metrics using PushGateway

我正在尝试使用 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)

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

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

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

The URL up to http://169.41.73.106:30000/metrics works fine

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

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

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

我收到此 404 错误,因为我的 url 类似于:

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