How to push Prometheus metrics in Grafana Cloud?

Hello all!
First of all, I would like to apologize if this question is trivial - or already answered many times - but I must confess that I am a bit lost…

I am developing an application that is able to send its own metrics or publish an endpoint ready to be scrapped by Prometheus. This works perfectly when pushing to a Pushgateway - so without agent.

Now I wish I had the same way of working with Grafana Cloud and sending those metrics there, again, without agent. I understand that an endpoint is available for this (https://<host>.grafana.net/api/prom/push). But no matter how I do it, it doesn’t work (HTTP 400 or 404).

Could you tell me if I can actually use this endpoint as if it is a pushgateway? If so, how can I do it? If not, what is the “recommended” way to send metrics?

Many thanks in advance for your help :pray:

Hi Pierre!

The recommended way of sending your metrics to a Grafana Cloud Prometheus endpoint is not through a push gateway but via remote_write from either a local Prometheus or using the Grafana Agent, via their config YAML file. Since you’ve already developed a way to scrape your application’s metrics to a (local) Prometheus then this is likely the easier path for you than the agent. You’ll add the remote_write to your local Prometheus’ yaml config as shown here: Prometheus | Grafana Labs

Wherein:
url =
https://prometheus-blocks-prod-us-central1.grafana.net/api/prom/push (confirm this in your Grafana Cloud Portal under Prometheus > Details as some accounts may vary in their URL path)
username = Prometheus instanceID (also found in your Grafana Cloud Portal under Prometheus > Details)
password = Grafana.com API key (generated from your Grafana Cloud portal under “API Keys”)

To access your Grafana Cloud portal, go to Grafana.com > “My Account” or “Login”. Hope this was helpful!

Hello @ximenaaliaguilla and thanks for your answer.

Unfortunately, the production version of my app will not be public - so no way to scrap from Grafana Cloud (it’s only working on my dev environment to test the prometheus rendering).

I had hopes of doing something that didn’t require a local prometheus, like if my app is its own agent and uses directly the remote write endpoint…

I’m trying to do the same: “send metric to grafana cloud using only curl”
did you succeed ?

Tip: Be sure that your Grafana.com API key has the “MetricsPublisher” type role.

@fxpester the only fully supported way to send metrics to a Grafana Cloud hosted metrics endpoints are via the remote_write mechanism I described in an earlier reply (from an external Prometheus or the Grafana Agent) or, for Graphite metrics, as described here.

There is another experimental way to push Telegraf metrics to the hosted Prometheus endpoint in Grafana Cloud that you’re welcome to try here: Store and visualize Influx Telegraf data | Grafana Labs

However, using curl to push metrics to a Grafana Cloud hosted metrics endpoint would not otherwise be supported.