---
title: "Configure Prometheus remote write to send metrics to Grafana Cloud | Grafana Labs"
description: "How to configure Prometheus to send metrics to Grafana Cloud"
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Configure Prometheus remote write to send metrics to Grafana Cloud

In this milestone, you add a `remote_write` block to your Prometheus configuration file, usually `prometheus.yml`. Grafana Cloud generates the block for you on the **Hosted Prometheus metrics** setup page. It contains the `/api/prom/push` URL of your Grafana Cloud Metrics instance, your instance ID as the username, and an access policy token as the password.

You don’t need to leave your Grafana Cloud stack for any of this. The same values are also available from the **Prometheus** card in the Cloud Portal.

First, open the setup page for hosted Prometheus metrics.

1. In the navigation menu, click **Connections**.
2. Click **Add new connection**.
3. In the search field, enter **Hosted Prometheus** to filter the catalog.
4. Click the **Hosted Prometheus metrics** tile.

The setup page is open. It walks you through choosing a method, creating a token, and copying the configuration.

Next, choose the remote write method and create a token. Creating a token needs the **Admin** role in your stack.

1. Under **Choose a method for forwarding metrics**, select **From my local Prometheus server**.
   
   The page preselects **Via Grafana Alloy**, which installs a separate collector. This path uses the remote write built into Prometheus instead.
2. Under **Choose your use case for forwarding metrics**, select **Send metrics from a single Prometheus instance**.
   
   The other cards cover multiple or high-availability Prometheus servers. The page adjusts its instructions if you pick one of those.
3. Under **Select how to send the metrics from Prometheus to Grafana Cloud**, keep **Directly** selected.
4. Under **Update Prometheus configuration**, keep **Create a new token** selected and enter a **Token name** you’ll recognize, for example `prometheus-remote-write`.
5. Click **Create token**.
   
   Grafana Cloud creates an access policy token and inserts it as the password in the `remote_write` configuration that appears below. The token is only shown once, so keep this page open until you’ve copied the configuration.
6. Below the configuration, click **Copy to clipboard**.
   
   The block contains the URL of your Grafana Cloud Metrics instance, your instance ID as the username, and the token as the password.

You have a `remote_write` block with your stack’s endpoint and credentials.

Now add it to Prometheus. These steps happen on the machine that runs Prometheus, so this path can’t detect them. When Prometheus restarts cleanly, mark the section as complete to continue.

1. Log in to the machine on which Prometheus is installed, and open a terminal.
2. If your user can’t write to the Prometheus configuration file, switch to one that can.
   
   For example:
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   sudo su -
   ```
3. Open `prometheus.yml` in a text editor. On many Linux installations the file is in `/etc/prometheus`.
   
   For example, with Vim, run:
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   vim /etc/prometheus/prometheus.yml
   ```
4. Scroll to the end of the file and paste the `remote_write` block you copied.
   
   In Vim, press `i` to start editing before you paste. The result looks like this, with your own values in place of the placeholders:
   
   YAML ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```yaml
   remote_write:
     - url: <Your Metrics instance remote_write endpoint>
       basic_auth:
         username: <Your Metrics instance ID>
         password: <Your Cloud Access Policy token>
   ```
   
   If the file already has a `remote_write` section, add the new entry to that list instead of adding a second `remote_write` key.
5. Save the file and exit the editor.
   
   In Vim, press `Esc`, then type `:wq` and press `Enter`.
6. Restart Prometheus so it reads the new configuration.
   
   For example, if Prometheus runs as a systemd service:
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   systemctl restart prometheus
   ```
   
   After the restart, Prometheus starts pushing the samples it scrapes to Grafana Cloud.
7. Check that Prometheus restarted without errors:
   
   ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
   
   ```none
   systemctl status prometheus
   ```
   
   If the service failed to start, a common cause is a YAML indentation error in the block you pasted. Check the service logs with `journalctl -u prometheus` or in `/var/log/syslog`.

Prometheus now has a second destination for the samples it scrapes. Your scrape configuration, recording rules, and alerts don’t change.

In the next milestone, you verify that your metrics are arriving in Grafana Cloud.

* * *

### More to explore (optional)

- [Send data from multiple Prometheus instances](/docs/grafana-cloud/send-data/metrics/metrics-prometheus/#send-data-from-multiple-prometheus-instances)
- [Send data from multiple high-availability Prometheus instances](/docs/grafana-cloud/send-data/metrics/metrics-prometheus/#send-data-from-multiple-high-availability-prometheus-instances)
- [Send Prometheus native histograms](/docs/grafana-cloud/send-data/metrics/metrics-prometheus/native-histograms/)

Were you successful?

![No](/media/images/svg/thumbs-up.svg) No

![Yes](/media/images/svg/thumbs-up.svg) Yes

Super! You can move to the next step.

* * *

### Troubleshooting

Explore the following troubleshooting topics if you need help:

- [Read-only or can’t open file message when editing prometheus.yml](/docs/grafana-cloud/send-data/metrics/metrics-prometheus/#receive-read-only-or-cant-open-file-message)
- [Troubleshoot Cloud Metrics write issues](/docs/grafana-cloud/send-data/metrics/troubleshoot/)

Please tell us what didn't work:

Submit

Submitting...

There was an error with your submission.

Thank you!

Need more support? Check out these [helpful resources.](/help/)
