Enabling CORS for Embedding Grafana in an iframe

Set up the Grafana server

Ensure you have a running instance of Grafana. You can verify this by accessing your Grafana URL in a browser.

Modify the Grafana configuration file

  1. Access the Grafana configuration file : This file is typically located at C:\Program Files\GrafanaLabs\grafana\conf\grafana.ini Grafana installation (Windows).
  2. Open the configuration file : Open the grafana.ini file in a text editor.
  3. Locate the HTTP section : In the grafana.ini file, find the [server] section. If you can’t find it, you can search for server or scroll down to the relevant section.
  4. Enable Cross-Origin Resource Sharing (CORS) : In the [server] section, look for the allow_embedding setting. Set it to true:

[server]

Enable embedding of Grafana dashboards

allow_embedding = true
image

This allows Grafana to be embedded within an iframe.

Restart the Grafana server

For the changes to take effect, you need to restart the Grafana server. Go to services and restart grafana service.