content/shared/v3-process-data/visualize/grafana.md
Use Grafana or Grafana Cloud to query and visualize data from {{% product-name %}}.
[!Note] {{< influxdb-version-detector context="grafana" >}}
[Grafana] enables you to query, visualize, alert on, and explore your metrics, logs, and traces wherever they are stored. [Grafana] provides you with tools to turn your time-series database (TSDB) data into insightful graphs and visualizations.
{{% cite %}}-- Grafana documentation{{% /cite %}}
Sign up for Grafana Cloud or follow the Grafana installation instructions to install Grafana for your operating system.
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 "core,enterprise,clustered" %}}
[!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 %}}
The InfluxDB data source plugin is included in the Grafana core distribution. Use the plugin to query and visualize data from {{< product-name >}} with both SQL and InfluxQL.
[!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 updated plugin includes SQL support for InfluxDB 3-based products such as {{< product-name >}}, and the interface dynamically adapts based on your product and query language selection in URL and authentication.
Prerequisites:
| Configuration | Value |
|---|---|
| Product selection | {{% hide-in "core,enterprise" %}}{{% product-name %}}{{% /hide-in %}}{{% show-in "core" %}}InfluxDB Enterprise 3.x (currently, no Core menu option){{% /show-in %}}{{% show-in "enterprise" %}}InfluxDB Enterprise 3.x{{% /show-in %}} |
| URL | {{% show-in "cloud-dedicated,clustered" %}} Cluster URL{{% /show-in %}}{{% show-in "cloud-serverless" %}} Region URL--for example, https://us-west-2-1.aws.cloud2.influxdata.com{{% /show-in %}}{{% show-in "core,enterprise" %}}Server URL{{% /show-in %}}{{% hide-in "cloud-serverless" %}}--for example, https://{{< influxdb/host >}}{{% /hide-in %}} |
| Query languages | SQL (requires HTTP/2), InfluxQL |
| Authentication | {{% show-in "cloud-serverless" %}}Required (API token){{% /show-in %}}{{% show-in "core" %}}Admin token (if authentication is enabled){{% /show-in %}}{{% show-in "enterprise" %}}Admin or database token (if authentication is enabled){{% /show-in %}}{{% show-in "cloud-dedicated,clustered" %}}Required (database token){{% /show-in %}} |
| Database/Bucket | {{% show-in "cloud-serverless" %}}Bucket name{{% /show-in %}}{{% hide-in "cloud-serverless" %}}Database name{{% /hide-in %}} |
In the URL and authentication section, configure the following:
https://us-west-2-1.aws.cloud2.influxdata.com{{% /show-in %}}{{% show-in "core,enterprise" %}} server URL{{% /show-in %}}{{% hide-in "cloud-serverless" %}}--for example, https://{{< influxdb/host >}}{{% /hide-in %}}The fields in this section change based on your query language selection in URL and authentication.
{{< tabs-wrapper >}} {{% tabs %}} SQL InfluxQL {{% /tabs %}} {{% tab-content %}}
<!--------------------------------- BEGIN SQL --------------------------------->When you select SQL as the query language, configure the following fields:
Database: {{% show-in "cloud-serverless" %}}Your bucket name. In {{< product-name >}}, buckets function as databases.{{% /show-in %}}{{% hide-in "cloud-serverless" %}}Your database name.{{% /hide-in %}}
Token: {{% show-in "cloud-serverless" %}}An API token with read access to the bucket{{% /show-in %}}{{% show-in "cloud-dedicated,clustered" %}}A database token with read access to the database{{% /show-in %}}{{% show-in "core,enterprise" %}}Your {{% token-link "admin" "database" %}} with read access to the database{{% /show-in %}}
{{% show-in "cloud-serverless" %}}{{< img-hd src="/img/grafana/influxdb3-cloud-serverless-grafana-sql.png" alt="SQL configuration for {{% product-name %}}" />}}{{% /show-in %}} {{% show-in "cloud-dedicated" %}}{{< img-hd src="/img/grafana/influxdb3-cloud-dedicated-grafana-sql.png" alt="SQL configuration for {{% product-name %}}" />}}{{% /show-in %}} {{% show-in "clustered" %}}{{< img-hd src="/img/grafana/influxdb3-clustered-grafana-sql.png" alt="SQL configuration for {{% product-name %}}" />}}{{% /show-in %}} {{% show-in "core" %}}{{< img-hd src="/img/grafana/influxdb3-core-grafana-sql.png" alt="SQL configuration for {{% product-name %}}" />}}{{% /show-in %}} {{% show-in "enterprise" %}}{{< img-hd src="/img/grafana/influxdb3-enterprise-grafana-sql.png" alt="SQL configuration for {{% product-name %}}" />}}{{% /show-in %}}
{{% show-in "core,enterprise,clustered" %}}
If using SQL to query {{% product-name %}} without TLS/SSL, enable the Insecure Connection option in your InfluxDB datasource configuration:
{{% img-hd src="/img/grafana/grafana-sql-insecure-connection.png" alt="Query InfluxDB using SQL without TLS/SSL" /%}} {{% /show-in %}}
[!Important]
Grafana queries through a proxy require HTTP/2
For SQL queries, Grafana uses the Flight SQL protocol (gRPC) to query {{% product-name %}}, which requires HTTP/2. If you query {{% product-name %}} through a proxy (such as HAProxy, nginx, or a load balancer), verify that your proxy is configured to support HTTP/2. Without HTTP/2 support, SQL queries through Grafana will fail to connect.
InfluxQL queries use HTTP/1.1 and are not affected by this requirement.
Click Save & test. Grafana attempts to connect to {{% product-name %}} and returns the result of the test.
<!---------------------------------- END SQL ---------------------------------->{{% /tab-content %}} {{% tab-content %}}
<!------------------------------- BEGIN INFLUXQL ------------------------------>{{% show-in "cloud-serverless" %}}
[!Important]
DBRP mapping required
To query {{% product-name %}} with InfluxQL, you must first map database and retention policy (DBRP) combinations to your InfluxDB Cloud buckets. The configuration form displays a warning if DBRP mapping is not configured.
For more information, see Map databases and retention policies to buckets. {{% /show-in %}}
When you select InfluxQL as the query language, configure the following fields:
Database: {{% show-in "cloud-serverless" %}}The database name mapped to your InfluxDB bucket.{{% /show-in %}}{{% hide-in "cloud-serverless" %}}Your database name.{{% /hide-in %}}
User: A username (can be any non-empty value).
Password: {{% show-in "cloud-serverless" %}}Your API token with read access to the bucket.{{% /show-in %}}{{% hide-in "cloud-serverless" %}}Your database token with read access to the database.{{% /hide-in %}}
HTTP Method: Select POST (recommended) or GET
{{% show-in "cloud-serverless" %}}{{< img-hd src="/img/grafana/influxdb3-cloud-serverless-grafana-influxql.png" alt="InfluxQL configuration for {{% product-name %}} with DBRP warning" />}}{{% /show-in %}} {{% show-in "cloud-dedicated" %}}{{< img-hd src="/img/grafana/influxdb3-cloud-dedicated-grafana-influxql.png" alt="InfluxQL configuration for {{% product-name %}} with DBRP warning" />}}{{% /show-in %}} {{% show-in "clustered" %}}{{< img-hd src="/img/grafana/influxdb3-clustered-grafana-influxql.png" alt="InfluxQL configuration for {{% product-name %}} with DBRP warning" />}}{{% /show-in %}} {{% show-in "core" %}}{{< img-hd src="/img/grafana/influxdb3-core-grafana-influxql.png" alt="InfluxQL configuration for {{% product-name %}}" />}}{{% /show-in %}} {{% show-in "enterprise" %}}{{< img-hd src="/img/grafana/influxdb3-enterprise-grafana-influxql.png" alt="InfluxQL configuration for {{% product-name %}} with DBRP warning" />}}{{% /show-in %}}
Click Save & test. Grafana attempts to connect to {{% product-name %}} and returns the result of the test.
<!-------------------------------- END INFLUXQL ------------------------------->{{% /tab-content %}} {{< /tabs-wrapper >}}
With your InfluxDB connection configured, use Grafana to query and visualize time series data.
After you configure and save an InfluxDB datasource, use Grafana to build, run, and inspect queries against {{% show-in "cloud-serverless" %}}your InfluxDB bucket{{% /show-in %}}{{% hide-in "cloud-serverless" %}}{{% product-name %}}{{% /hide-in %}}.
{{< tabs-wrapper >}} {{% tabs %}} SQL InfluxQL {{% /tabs %}} {{% tab-content %}}
<!--------------------------------- BEGIN SQL --------------------------------->[!Note] {{% sql/sql-schema-intro %}} To learn more, see Query Data.
Click Explore.
In the dropdown, select the saved InfluxDB data source to query.
Use the SQL query form to build your query:
Table: Select the table (measurement) to query.
Column: Select one or more fields and tags to return as columns in query results.
With SQL, select the time column to include timestamps with the data.
Grafana relies on the time column to correctly graph time series data.
Optional: Toggle filter to generate WHERE clause statements.
WHERE clause.Optional: Toggle group to generate GROUP BY clause statements.
{{< req text="Recommended" color="green" >}}: Toggle order to generate ORDER BY clause statements.
{{< req text="Recommended" color="green" >}}: Change format to Time series.
Click Run query to execute the query.
{{% /tab-content %}} {{% tab-content %}}
<!------------------------------- BEGIN INFLUXQL ------------------------------>GROUP BY clause.{{% /tab-content %}} {{< /tabs-wrapper >}}
With your InfluxDB connection configured, use Grafana to query and visualize time series data.
For a comprehensive walk-through of creating visualizations with Grafana, see the Grafana documentation.
To learn more about query management and inspection in Grafana, see the Grafana Explore documentation.