S.A.Norton Stanley
S.A.Norton Stanley

Reputation: 1873

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

I am trying to push metrics using PushGateway, and i get the below error while pushing the metrics:

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)

The URL up to http://169.41.73.106:30000/metrics works fine, however when I try /metrics/job with any of the scrape job names mentioned I get 404. Can someone help.

Upvotes: 3

Views: 16886

Answers (3)

banarasi
banarasi

Reputation: 69

Posting my answer just in case. If someone lands on the same error and above 2 Answers don't help.

You may receive same 404 error if the Pushgateway URL you are posting the metrics doesn't have "job" word (keyword which will be used while Prometheus scrapes).

I was getting this 404 error as my url was something like:

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

I was able to resolve the issue by using the url:

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

Upvotes: 0

Alex S.
Alex S.

Reputation: 81

If you guys see 404 response during building POC or configuring new environment, you likely made the same mistake as I made. I was using Prometheus web server URL instead of the push gateway web server URL. These are two different web servers. They may run on the same host, but on the different ports or be located on the totally different servers. In may case these are two different domains, which look like: https://prometheus.company.com and https://prometheus-pushgateway.company.com

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

GET on /mertics endpoint should not work fine when you open push gateway, but works on prometheus web server. Use /mertics endpoint to find, which server do you use.

Upvotes: 1

Graham
Graham

Reputation: 56

https://github.com/Prometheus/pushgateway I think you need to set up pushgateway at first ,then add pushgateway's address+port (localhost:9091) to prometheus config file, then run you pushgateway client to send metrics again, it works for me

Upvotes: 3

Related Questions