Error when connecting Prometheus Datasource (local server) to Grafana cloud

  • What Grafana version and what operating system are you using? Grafana cloud

  • What are you trying to achieve?
    Connect Local Prometheus Datasource to Grafana cloud.

  • How are you trying to achieve it?
    I have install Prometheus on a ec2 server with a node_exporter.

prometheus, version 3.1.0 (branch: HEAD, revision: 7086161a93b262aa0949dbf2aba15a5a7b13e0a3)
build user: root@74c225e2044f
build date: 20250102-13:52:43
go version: go1.23.4
platform: linux/amd64
tags: netgo,builtinassets,stringlabels

node_exporter, version 1.8.2 (branch: HEAD, revision: f1e0e8360aa60b6cb5e5cc1560bed348fc2c1895)
build user: root@03d440803209
build date: 20240714-11:53:45
go version: go1.22.5
platform: linux/amd64
tags: unknown

The Prometheus UI works and I have able to run querys.
I have a Grafana cloud account and I tried to add Prometheus Data sources,
Home > Connections > Data sources > prometheus

  • What happened?
    There was an error returned querying the Prometheus API.

  • What did you expect to happen?
    success connections as I see when I run the same API in my browser:
    {“status”:“success”,“data”:{“resultType”:“scalar”,“result”:[4,“2”]}}

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

Get http://<DNS NAME>:9090/api/v1/query?query=1%2B1&time=4": dial tcp <MY IP>:9090: i/o timeout- There was an error returned querying the Prometheus API.

  • Did you follow any online instructions? If so, what is the URL?
    Grafana Cloud

Make sure that http://<DNS NAME>:9090 is available from Grafana Cloud (public internet), not just from your browser. (It is an ec2 server, so EC2 must have a public IP, the correct security group, …). If you don’t want to create public-facing Prometheus, then PDC is a an option.

That’s what I meant when I wrote ‘from my browser’
I was able to connect my local Prometheus to grafana-cloud by using the Hosted Prometheus metrics on grafana-cloud:
Home > Connections > Add new connection > Hosted Prometheus metrics
And adding remote_write:

remote_write:

Now I need to figure out how I create convenient dashboards on grafana-cloud.

Thanks