This is documentation for the next version of Grafana documentation. For the latest stable release, go to the latest version.
Configure the Graphite data source
This document provides instructions for configuring the Graphite data source and explains available configuration options. For general information on managing data sources, refer to Data source management.
Before you begin
You must have the
Organization administratorrole to configure the Graphite data source. Organization administrators can also configure the data source via YAML with the Grafana provisioning system.Grafana comes with a built-in Graphite data source plugin, eliminating the need to install a plugin.
Familiarize yourself with your Graphite security configuration and gather any necessary security certificates and client keys.
Add the Graphite data source
To configure basic settings for the data source, complete the following steps:
- Click Connections in the left-side menu.
- Click Add new connection
- Type
Graphitein the search bar. - Select the Graphite data source.
- Click Add new data source in the upper right.
Grafana takes you to the Settings tab, where you set up your Graphite configuration.
Configuration options in the UI
Following is a list of configuration options for Graphite.
HTTP:
Auth:
Custom HTTP Headers:
Pass along additional information and metadata about the request or response.
Graphite details:
Label mappings:
Label mappings are the rules you define to tell Grafana how to pull pieces of the Graphite metric path into Loki labels when switching data sources. They are currently only supported between Graphite and Loki queries.
When you change your data source from Graphite to Loki, your queries are automatically mapped based on the rules you define. To create a mapping, specify the full path of the metric and replace the nodes you want to map with label names, using parentheses. The corresponding label values are extracted from your Graphite query during the data source switch.
Grafana automatically maps all Graphite tags to labels, even if you haven’t defined explicit mappings. When using matching patterns with {} (for example, metric.{a,b}.value), Grafana converts them to the Loki regular expression matching syntax. If your queries include functions, Graphite extracts the relevant metrics and tags, then matches them against your mappings.
For example, given the mapping servers.(cluster).(server).*:
After configuring your Graphite data source options, click Save & test at the bottom to test the connection. You should see a confirmation dialog box that says:
Data source is working
Provision the data source
You can define and configure the data source in YAML files as part of the Grafana provisioning system. For more information about provisioning, and for lists of common configuration options and JSON data options, refer to Provisioning data sources.
YAML example
The following example provisions a Graphite data source:
apiVersion: 1
datasources:
- name: Graphite
type: graphite
access: proxy
url: http://localhost:8080
jsonData:
graphiteVersion: '1.1'
graphiteType: defaultThe following jsonData options are supported:
Provision with Terraform
You can provision the Graphite data source using Terraform with the Grafana Terraform provider.
For more information about provisioning resources with Terraform, refer to the Grafana as code using Terraform documentation.
Terraform example
The following example provisions a Graphite data source:
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
version = ">= 2.0.0"
}
}
}
provider "grafana" {
url = "<YOUR_GRAFANA_URL>"
auth = "<YOUR_SERVICE_ACCOUNT_TOKEN>"
}
resource "grafana_data_source" "graphite" {
type = "graphite"
name = "Graphite"
url = "http://localhost:8080"
json_data_encoded = jsonencode({
# Graphite version: 0.9, 1.0, or 1.1
graphiteVersion = "1.1"
# Backend type: default or metrictank
graphiteType = "default"
})
}Terraform example with basic authentication
The following example provisions a Graphite data source with basic authentication:
resource "grafana_data_source" "graphite_auth" {
type = "graphite"
name = "Graphite"
url = "http://localhost:8080"
basic_auth_enabled = true
basic_auth_username = "<USERNAME>"
json_data_encoded = jsonencode({
graphiteVersion = "1.1"
graphiteType = "default"
})
secure_json_data_encoded = jsonencode({
basicAuthPassword = "<PASSWORD>"
})
}Replace the following placeholders:
<YOUR_GRAFANA_URL>: Your Grafana instance URL (for example,https://your-org.grafana.netfor Grafana Cloud)<YOUR_SERVICE_ACCOUNT_TOKEN>: A service account token with data source permissions<USERNAME>: The username for basic authentication<PASSWORD>: The password for basic authentication


