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

# Configure Prometheus remote write to send metrics to Grafana Cloud

In this step of the journey you’ll update a YAML file in your Prometheus installation with a snippet of code taken from your Grafana Cloud Portal account. The snippet of code provides Prometheus with the URL of the Grafana Cloud metrics instance and credentials for sending metrics. Watch video -&gt;

To configure Prometheus to remote write to Grafana Cloud, complete the following steps:

01. Log into your Cloud Portal and select your stack.
02. Click the name of your stack under **Grafana Cloud** located on the left navigation panel.
03. On the **Prometheus** tile, click **Send Metrics**.
04. Scroll down the page until you locate the **Sending metrics with Prometheus** section.
    
    This section contains a snippet of code that you’ll add to your Prometheus deployment.
05. Just below the code sample, click **Generate now** to generate an API token.
    
    The API token ensures a secure connection to Grafana Cloud.
06. On the **Create an API token** screen, enter a name for the token and click **Create token**.
    
    The code snippet populates with the token you just created.
07. On the **Create an API token** screen, click **Close**.
08. Just below the code snippet, click **Copy to clipboard**.
    
    In the following steps, you’ll add the code snippet to the `prometheus.yml` file.
09. Log into the machine on which Prometheus is installed.
10. Open a terminal and if required, switch to a user with write privileges.
    
    For example:
    
    ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
    
    ```none
    sudo su -
    ```
11. Open the `prometheus.yml` file located under `/etc/prometheus`.
    
    For example, if you are using Vim, run:
    
    ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
    
    ```none
    vim /etc/prometheus/prometheus.yml
    ```
12. Edit the YAML file.
    
    When using Vi or Vim as the text editor, press `i` to edit the YAML file.
    
    The button you use to the edit the YAML file depends on the text editor you are using.
13. Scroll to the end of the file and paste the snippet of code you copied from the Grafana Cloud Portal.
14. Exit edit mode and save your changes.
    
    For example, when using Vi or Vim, press the `Esc` key to exit insert mode type `:wq` to save your changes and exit.
15. Restart the Prometheus service to apply the changes.
    
    For example: run the command
    
    ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
    
    ```none
    systemctl restart prometheus.yml
    ```
    
    After restarting the Prometheus service, metrics should be forwarded to Grafana Cloud.
16. To check the Prometheus service status, run the following command:
    
    ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy
    
    ```none
    systemctl status prometheus.service
    ```
    
    If there are errors, refer to the relevant logs in `/var/log/syslog` or `journalctl`.

In the next stop in your journey, you’ll verify that Prometheus is sending metrics to Grafana Cloud.

* * *

### Troubleshooting

Explore the following troubleshooting topics if you need help:

- [/etc/prometheus/prometheus.yml is read-only](/docs/grafana-cloud/send-data/metrics/metrics-prometheus/#troubleshooting)
- [/etc/prometheus/prometheus.yml Can’t open file for writing](/docs/grafana-cloud/send-data/metrics/metrics-prometheus/#troubleshooting)

* * *

### 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)
