Grafana only return 404 from my Prometheus data source


(due to the limitation on writing url for new user, I had to mess up some url)

I have a server that has prometheus data source running on localhost:9180.
Running curl htt p://localhost:9180/metrics on the server does indeed return the metrics.
Now, I have a Grafana running on the same server, that I expose to the internet via a reverse proxy.
I access Grafana through the internet-exposed url grafana.mywebiste .com.
I configured graphana with the domain grafana.mywebsite .com and the root_url https://

I can access the grafana web client with no issue, but when I try to add my Prometheus data source via the Grafana web client, using url = htt p://localhost:9180, clicking “save & test” show me an error box with the message “HTTP Error Not Found”.

When looking through my browser request, I see the request to /api/datasources/proxy/2/api/v1/query?query=1%2B1&time=1575645893.174 returning 404.

The log of Grafana also show that the request return 404.

When trying to create a request through Grafana to this data source, I get the same result.

The Prometheus should be available to Grafana since they are running on the same machine.

Can someone help me understand the issue ?

1 Like

Hi I am also facing the same problem.

Metrics can be pulled by browser in the new tab and even curl is pulling the data in the host.

I have also disabled CORS security in the browser as well.

What could be the reason? Please advise

Use the server access instead of browser following information below…

no doubt the OPs have moved along or figured things out, but i believe your problem is you are not running a prometheus instance. you need three ingredients for this cake; a server which generates metrics (which you have), prometheus (which you don’t have), and grafana. the metric server makes the data (duh), prometheus scrapes the data from that server and stores in a timeseries db, and then grafana which connects to your prometheus instance to request queries (eg, query?query=1%2B1&time=1575645893.174)

i have to say, this confused me for a bit too, it isn’t clear in grafana that it will only connect to a prometheus instance. if you see things like this, then you are pointing grafana at your server that generates the metrics, rather than the prometheus server (which is a database of metrics)

When looking through my browser request, I see the request to /api/datasources/proxy/2/api/v1/query?query=1%2B1&time=1575645893.174 returning 404.

fwiw, this great tutorial sorted me out : Get started with Prometheus with these three easy projects | Grafana Labs