content/shared/influxdb-v2/tools/grafana.md
Use Grafana or Grafana Cloud to visualize data from your InfluxDB {{< current-version >}} instance.
[!Note] {{< influxdb-version-detector context="grafana" >}}
[!Note]
Grafana 12.2+
The instructions below are for Grafana 12.2+ with the
newInfluxDSConfigPageDesignfeature flag enabled. This introduces the newest version of the InfluxDB core plugin. The interface dynamically adapts based on your product and query language selection in URL and authentication.
If running Grafana locally, enable the newInfluxDSConfigPageDesign feature flag to use the latest InfluxDB data source plugin.
{{< expand-wrapper >}} {{% expand "Option 1: Configuration file (recommended)" %}}
Add the following to your grafana.ini configuration file:
[feature_toggles]
enable = newInfluxDSConfigPageDesign
Configuration file locations:
/etc/grafana/grafana.ini/opt/homebrew/etc/grafana/grafana.ini<GRAFANA_INSTALL_DIR>\conf\grafana.ini{{% /expand %}}
{{% expand "Option 2: Command line" %}}
Enable the feature flag when starting Grafana:
{{< code-tabs-wrapper >}} {{% code-tabs %}} Linux macOS (Homebrew) Windows {{% /code-tabs %}} {{% code-tab-content %}}
grafana-server --config /etc/grafana/grafana.ini \
cfg:default.feature_toggles.enable=newInfluxDSConfigPageDesign
{{% /code-tab-content %}} {{% code-tab-content %}}
/opt/homebrew/opt/grafana/bin/grafana server \
--config /opt/homebrew/etc/grafana/grafana.ini \
--homepath /opt/homebrew/opt/grafana/share/grafana \
--packaging=brew \
cfg:default.paths.logs=/opt/homebrew/var/log/grafana \
cfg:default.paths.data=/opt/homebrew/var/lib/grafana \
cfg:default.paths.plugins=/opt/homebrew/var/lib/grafana/plugins \
cfg:default.feature_toggles.enable=newInfluxDSConfigPageDesign
{{% /code-tab-content %}} {{% code-tab-content %}}
grafana-server.exe --config <GRAFANA_INSTALL_DIR>\conf\grafana.ini `
cfg:default.feature_toggles.enable=newInfluxDSConfigPageDesign
{{% /code-tab-content %}} {{< /code-tabs-wrapper >}}
{{% /expand %}} {{< /expand-wrapper >}}
For more information, see Configure feature toggles in the Grafana documentation.
Visit your Grafana Cloud user interface (UI) or, if running Grafana locally, start Grafana and visit http://localhost:3000 in your browser.
{{% show-in "v2" %}}
[!Note]
Using Grafana Cloud with a local InfluxDB instance
If you need to keep your database local, consider running Grafana locally instead of using Grafana Cloud, as this avoids the need to expose your database to the internet.
To use InfluxDB running on your private network with Grafana Cloud, you must configure a private data source for Grafana Cloud. {{% /show-in %}}
[!Note] SQL is only supported in InfluxDB 3. {{% show-in "v2" %}}For more information, see how to get started with InfluxDB 3 Core.{{% /show-in %}}{{% show-in "cloud" %}}For more information, see how to upgrade to InfluxDB Cloud Serverless.{{% /show-in %}}
| Configuration | Value |
|---|---|
| Product selection | {{% show-in "v2" %}}InfluxDB OSS 2.x{{% /show-in %}}{{% show-in "cloud" %}}InfluxDB Cloud (TSM){{% /show-in %}} |
| URL | {{% show-in "v2" %}}Server URL--for example, https://{{< influxdb/host >}}{{% /show-in %}}{{% show-in "cloud" %}}Region URL--for example, https://us-east-2-1.aws.cloud2.influxdata.com{{% /show-in %}} |
| Query languages | Flux, InfluxQL |
| Authentication | API token or v1 username/password |
| Organization | Organization name or ID (Flux only) |
| Default Bucket | Default bucket for Flux queries (Flux only) |
| Database | Database name mapped to bucket (InfluxQL only) |
In the URL and authentication section, configure the following:
https://{{< influxdb/host >}}{{% /show-in %}}{{% show-in "cloud" %}}region URL--for example, https://us-east-2-1.aws.cloud2.influxdata.com{{% /show-in %}}The fields in this section change based on your query language selection in URL and authentication.
{{< tabs-wrapper >}}
{{% tabs %}}
Flux
InfluxQL
{{% /tabs %}}
{{% tab-content %}}
When you select Flux as the query language, configure the following:
{{% show-in "v2" %}}{{< img-hd src="/img/grafana/influxdb-v2-grafana-influxql-flux.png" alt="Flux configuration for InfluxDB OSS 2.x" />}}{{% /show-in %}} {{% show-in "cloud" %}}{{< img-hd src="/img/grafana/influxdb-cloud-grafana-flux.png" alt="Flux configuration for InfluxDB Cloud (TSM)" />}}{{% /show-in %}}
Click Save & Test. Grafana attempts to connect to {{% show-in "v2" %}}InfluxDB OSS 2.x{{% /show-in %}}{{% show-in "cloud" %}}InfluxDB Cloud{{% /show-in %}} and returns the results of the test.
<!---------------------------------- END FLUX ---------------------------------->{{% /tab-content %}} {{% tab-content %}}
<!------------------------------- BEGIN INFLUXQL ------------------------------>[!Important]
DBRP mapping required
To query InfluxDB OSS 2.x with InfluxQL, you must first create Database and Retention Policy (DBRP) mappings. The configuration form displays a warning if DBRP mapping is required.
When you select InfluxQL as the query language, you can authenticate using either tokens or username/password credentials.
Configure the following fields:
Configure the following fields:
{{% show-in "v2" %}}{{< img-hd src="/img/grafana/influxdb-v2-grafana-influxql.png" alt="InfluxQL configuration for InfluxDB OSS 2.x with DBRP warning" />}}{{% /show-in %}} {{% show-in "cloud" %}}{{< img-hd src="/img/grafana/influxdb-cloud-grafana-influxql.png" alt="InfluxQL configuration for InfluxDB Cloud (TSM) with v1 auth" />}}{{% /show-in %}}
Click Save & Test. Grafana attempts to connect to {{% show-in "v2" %}}InfluxDB OSS 2.x{{% /show-in %}}{{% show-in "cloud" %}}InfluxDB Cloud{{% /show-in %}} and returns the results of the test.
When using InfluxQL to query InfluxDB, the query must specify a database and retention policy. InfluxDB DBRP mappings associate database and retention policy combinations with InfluxDB OSS 2.x buckets.
Use the influx v1 dbrp list command:
influx v1 dbrp list
Use the influx v1 dbrp create command:
influx v1 dbrp create \
--db example-db \
--rp example-rp \
--bucket-id 00xX00o0X001 \
--default
Provide:
--db: Database name--rp: Retention policy name (not retention period)--bucket-id: Bucket ID--default: (Optional) Make this the default retention policy for the database[!Note] Repeat for each DBRP combination Each unique database and retention policy combination used by Grafana must be mapped to an InfluxDB OSS 2.x bucket.
For more information, see Database and retention policy mapping.
InfluxDB OSS 2.x provides a v1-compatible authentication API for username/password authentication.
Use the influx v1 auth list command:
influx v1 auth list
Use the influx v1 auth create command:
influx v1 auth create \
--read-bucket 00xX00o0X001 \
--write-bucket 00xX00o0X001 \
--username example-user
Provide:
--read-bucket: Bucket ID to grant read permissions--write-bucket: Bucket ID to grant write permissions--username: New usernameYou'll be prompted to enter a password.
<!-------------------------------- END INFLUXQL ------------------------------->{{% /tab-content %}} {{< /tabs-wrapper >}}
With your InfluxDB connection configured, use Grafana to query and visualize time series data.
To learn about query management and inspection in Grafana, see the Grafana Explore documentation.
For a comprehensive walk-through of creating visualizations with Grafana, see the Grafana documentation.