Grafana Cloud Enterprise

Configure the Cloudflare data source

This document explains how to configure the Cloudflare data source in Grafana.

Before you begin

Before you configure the data source, ensure you have:

Required permissions

When creating your Cloudflare API token, add the following permissions based on the features you want to use. In the Cloudflare dashboard, permissions follow the format Category > Resource > Access Level.

CategoryResourceAccessScopeRequired for
AccountAccount SettingsReadAll accounts (or specific)Account queries
ZoneZoneReadAll zones (or specific)Zone queries
ZoneAnalyticsReadAll zones (or specific)DNS Analytics queries

Note

Cloudflare Radar queries don’t require any special permissions because Radar APIs are publicly accessible.

For security best practices:

  • Only grant permissions for the features you need
  • Limit scope to specific accounts or zones when possible
  • Use the principle of least privilege

For more information about Cloudflare API token permissions, refer to the Cloudflare permissions documentation.

Create an API token

To create an API token in Cloudflare:

  1. Go to the Cloudflare API Tokens page.
  2. Click Create Token.
  3. Select Create Custom Token.
  4. Add the required permissions (see Required permissions).
  5. Click Continue to summary, then Create Token.
  6. Copy the token and paste it into the Token field in Grafana.

For detailed instructions, refer to the Cloudflare documentation.

Note

The Cloudflare data source only supports user tokens. Account-owned tokens aren’t supported.

Add the data source

To add the Cloudflare data source:

  1. Click Connections in the left-side menu.
  2. Click Add new connection.
  3. Type Cloudflare in the search bar.
  4. Select Cloudflare.
  5. Click Add new data source.

Configure settings

Configure the following settings for the Cloudflare data source:

SettingDescription
NameThe name used to refer to the data source in panels and queries.
DefaultToggle to make this the default data source for new panels.

Authentication

SettingDescription
TokenYour Cloudflare API token.

Verify the connection

Click Save & test to verify the connection. A success message confirms that Grafana can connect to Cloudflare.

Provision the data source

You can define the data source in YAML files as part of the Grafana provisioning system. For more information, refer to Provision Grafana.

YAML
apiVersion: 1
datasources:
  - name: Cloudflare
    type: grafana-cloudflare-datasource
    secureJsonData:
      cloudflare.token: <YOUR_CLOUDFLARE_API_TOKEN>

Replace <YOUR_CLOUDFLARE_API_TOKEN> with your Cloudflare API token.

Provision with Terraform

You can provision the data source using the Grafana Terraform provider.

hcl
resource "grafana_data_source" "cloudflare" {
  type = "grafana-cloudflare-datasource"
  name = "Cloudflare"

  secure_json_data_encoded = jsonencode({
    "cloudflare.token" = var.cloudflare_api_token
  })
}

For more information, refer to the Grafana Terraform provider documentation.