Configure Prometheus remote write to send metrics to Grafana Cloud
To configure Prometheus to remote write to Grafana Cloud, complete the following steps:
Log into your Cloud Portal and select your stack.
Click the name of your stack under Grafana Cloud located on the left navigation panel.
On the Prometheus tile, click Send Metrics.
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.
Just below the code sample, click Generate now to generate an API token.
The API token ensures a secure connection to Grafana Cloud.
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.
On the Create an API token screen, click Close.
Just below the code snippet, click Copy to clipboard.
In the following steps, you’ll add the code snippet to the
prometheus.ymlfile.Log into the machine on which Prometheus is installed.
Open a terminal and if required, switch to a user with write privileges.
For example:
sudo su -Open the
prometheus.ymlfile located under/etc/prometheus.For example, if you are using Vim, run:
vim /etc/prometheus/prometheus.ymlEdit the YAML file.
When using Vi or Vim as the text editor, press
ito edit the YAML file.The button you use to the edit the YAML file depends on the text editor you are using.
Scroll to the end of the file and paste the snippet of code you copied from the Grafana Cloud Portal.
Exit edit mode and save your changes.
For example, when using Vi or Vim, press the
Esckey to exit insert mode type:wqto save your changes and exit.Restart the Prometheus service to apply the changes.
For example: run the command
systemctl restart prometheus.ymlAfter restarting the Prometheus service, metrics should be forwarded to Grafana Cloud.
To check the Prometheus service status, run the following command:
systemctl status prometheus.serviceIf there are errors, refer to the relevant logs in
/var/log/syslogorjournalctl.


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
- /etc/prometheus/prometheus.yml Can’t open file for writing
More to explore (optional)
Troubleshooting options
Please tell us what didn't work:
