docs/sources/datasources/influxdb/configure/_index.md
Learn how to configure the InfluxDB data source and explore the available configuration options.
To configure the InfluxDB data source, you must have the Administrator role.
InfluxData provides three query languages:
To help choose the best language for your needs, refer to a comparison of Flux vs InfluxQL and Why InfluxData created Flux.
If you're unsure which InfluxDB product you're using, refer to InfluxData's InfluxDB product detection tool for guidance.
Complete the following steps to set up a new InfluxDB data source:
InfluxDB in the search bar.Grafana opens the Settings tab where you configure the data source. A sidebar on the left displays navigation links to each configuration section:
The following sections describe the available configuration options.
First, configure the name of your connection.
InfluxDB-InfluxQL, InfluxDB_SQL.Use these settings to specify the InfluxDB instance the data source connects to.
8086. When you enter a URL, Grafana attempts to auto-detect your InfluxDB product based on URL patterns. Refer to InfluxDB detection for more information.The following table shows which query languages are available for each InfluxDB product:
| Product | Supported query languages |
|---|---|
| InfluxDB Cloud Dedicated | SQL, InfluxQL |
| InfluxDB Cloud Serverless | SQL, InfluxQL, Flux |
| InfluxDB Clustered | SQL, InfluxQL |
| InfluxDB Enterprise 1.x | InfluxQL, Flux |
| InfluxDB Enterprise 3.x | SQL, InfluxQL |
| InfluxDB Cloud (TSM) | InfluxQL, Flux |
| InfluxDB Cloud 1 | InfluxQL |
| InfluxDB OSS 1.x | InfluxQL, Flux |
| InfluxDB OSS 2.x | InfluxQL, Flux |
| InfluxDB OSS 3.x | SQL, InfluxQL |
{{< admonition type="note" >}} For InfluxQL only. Database + Retention Policy (DBRP) Mapping must be configured before data can be queried for the following products: InfluxDB OSS 1.x, InfluxDB OSS 2.x, InfluxDB Enterprise 1.x, InfluxDB Cloud (TSM), InfluxDB Cloud Serverless.
Refer to Manage DBRP Mappings for guidance on setting this up using the CLI or API. {{< /admonition >}}
Toggle Advanced HTTP Settings to expand optional settings for more control over your data source.
Custom HTTP headers
Click + Add header to add one or more HTTP headers. HTTP headers pass additional context and metadata about the request/response.
Toggle Auth and TLS/SSL Settings to expand authentication and security options.
TLS/SSL Certificates are encrypted and stored in the Grafana database.
Server name, Client cert and Client key. The client provides a certificate that the server validates to establish the client’s trusted identity. The client key encrypts the data between client and server.
server1.domain.com{{< admonition type="note" >}}
Setting the database for this data source does not deny access to other databases. The InfluxDB query syntax allows switching the database in the query. For example: SHOW MEASUREMENTS ON _internal or SELECT * FROM "_internal".."database" LIMIT 10
To support data isolation and security, make sure appropriate permissions are configured in InfluxDB. {{< /admonition >}}
Use these settings to specify the InfluxDB database your data source connects to. The required fields vary based on the query language selected in URL and authentication.
The following table shows which fields are required for each query language:
| Setting | Flux | InfluxQL | SQL |
|---|---|---|---|
| Organization | ✓ | ||
| Default Bucket | ✓ | ||
| Database | ✓ | ✓ | |
| User | ✓ | ||
| Password | ✓ | ||
| Token | ✓ | ✓ |
v.organization query macro.v.defaultBucket macro in Flux queries.For Flux
username:password.Toggle Advanced Database Settings to expand optional settings that give you more control over the query experience.
1000.For Flux and InfluxQL
10s. Refer to Min time interval for format examples.For InfluxQL
POST.For SQL
For Grafana Cloud only. Private data source connect (PDC) allows you to establish a private, secured connection between a Grafana Cloud instance and data sources secured within a private network. For more information, refer to Private data source connect (PDC).
Click Manage private data source connect to go to your PDC connection page, where you'll find your PDC configuration details.
After you have configured your connection settings, click Save & test to validate the data source connection.
A successful test returns one of the following messages depending on your query language:
| Query language | Success message |
|---|---|
| Flux | datasource is working. X buckets found |
| InfluxQL | datasource is working. X measurements found |
| SQL | OK |
If the test fails, refer to Troubleshoot InfluxDB data source issues for help resolving common connection and authentication errors.
The Min time interval setting defines a lower limit for the auto group-by time interval.
This value must be formatted as a number followed by a valid time identifier:
| Identifier | Description |
|---|---|
y | year |
M | month |
w | week |
d | day |
h | hour |
m | minute |
s | second |
ms | millisecond |
You can also override this setting in a dashboard panel under its data source options.
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 available configuration options, refer to Provision Grafana.
{{< admonition type="note" >}}
The database field is deprecated.
Grafana recommends using the dbName field in jsonData. There is no need to change existing provisioning settings.
{{< /admonition >}}
Provisioning differs based on query language.
InfluxDB 1.x example:
apiVersion: 1
datasources:
- name: InfluxDB_v1
type: influxdb
access: proxy
user: grafana
url: http://localhost:8086
jsonData:
dbName: site
httpMode: GET
secureJsonData:
password: grafana
InfluxDB 2.x for Flux example:
apiVersion: 1
datasources:
- name: InfluxDB_v2_Flux
type: influxdb
access: proxy
url: http://localhost:8086
jsonData:
version: Flux
organization: organization
defaultBucket: bucket
tlsSkipVerify: true
secureJsonData:
token: token
InfluxDB 2.x for InfluxQL example:
apiVersion: 1
datasources:
- name: InfluxDB_v2_InfluxQL
type: influxdb
access: proxy
url: http://localhost:8086
jsonData:
dbName: site
httpHeaderName1: 'Authorization'
secureJsonData:
httpHeaderValue1: 'Token <token>'
InfluxDB 3.x for SQL example:
apiVersion: 1
datasources:
- name: InfluxDB_v3_SQL
type: influxdb
access: proxy
url: http://localhost:8086
jsonData:
version: SQL
dbName: site
httpMode: POST
insecureGrpc: false
secureJsonData:
token: '<api-token>'
You can configure the InfluxDB data source using the Grafana Terraform provider.
Before you begin, you need:
Configure the Grafana provider to connect to your Grafana instance:
terraform {
required_providers {
grafana = {
source = "grafana/grafana"
version = ">= 2.0.0"
}
}
}
# For Grafana Cloud
provider "grafana" {
url = "<YOUR_GRAFANA_CLOUD_STACK_URL>"
auth = "<YOUR_SERVICE_ACCOUNT_TOKEN>"
}
# For self-hosted Grafana
# provider "grafana" {
# url = "http://localhost:3000"
# auth = "<API_KEY_OR_SERVICE_ACCOUNT_TOKEN>"
# }
The following examples show how to configure the InfluxDB data source for each query language.
InfluxDB 2.x with Flux:
resource "grafana_data_source" "influxdb_flux" {
type = "influxdb"
name = "InfluxDB_Flux"
url = "http://localhost:8086"
json_data_encoded = jsonencode({
version = "Flux"
organization = "<ORGANIZATION>"
defaultBucket = "<DEFAULT_BUCKET>"
tlsSkipVerify = false
})
secure_json_data_encoded = jsonencode({
token = "<API_TOKEN>"
})
}
InfluxDB 1.x with InfluxQL:
resource "grafana_data_source" "influxdb_influxql" {
type = "influxdb"
name = "InfluxDB_InfluxQL"
url = "http://localhost:8086"
basic_auth_enabled = true
basic_auth_username = "<USERNAME>"
json_data_encoded = jsonencode({
dbName = "<DATABASE>"
httpMode = "POST"
})
secure_json_data_encoded = jsonencode({
basicAuthPassword = "<PASSWORD>"
})
}
InfluxDB 2.x with InfluxQL (token auth):
resource "grafana_data_source" "influxdb_v2_influxql" {
type = "influxdb"
name = "InfluxDB_v2_InfluxQL"
url = "http://localhost:8086"
json_data_encoded = jsonencode({
dbName = "<DATABASE>"
httpHeaderName1 = "Authorization"
})
secure_json_data_encoded = jsonencode({
httpHeaderValue1 = "Token <API_TOKEN>"
})
}
InfluxDB 3.x with SQL:
resource "grafana_data_source" "influxdb_sql" {
type = "influxdb"
name = "InfluxDB_SQL"
url = "http://localhost:8086"
json_data_encoded = jsonencode({
version = "SQL"
dbName = "<DATABASE>"
httpMode = "POST"
insecureGrpc = false
})
secure_json_data_encoded = jsonencode({
token = "<API_TOKEN>"
})
}
For more information about the Grafana Terraform provider, refer to the Terraform provider documentation.