Documentation

Use Grafana to query and visualize data

Use Grafana to query and visualize data stored in InfluxDB Cloud Serverless. Install the grafana-flight-sql-plugin to query InfluxDB with the Flight SQL protocol.

[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.

Grafana documentation

Install Grafana or login to Grafana Cloud

If using the open source version of Grafana, follow the Grafana installation instructions to install Grafana for your operating system. If using Grafana Cloud, login to your Grafana Cloud instance.

Install the FlightSQL plugin

If you want to query InfluxDB Cloud Serverless with SQL, install the Grafana FlightSQL plugin.

Only required if using SQL

Installing the Grafana FlightSQL plugin is only required if using SQL to query data from InfluxDB. If using InfluxQL, enable the Grafana InfluxDB core plugin.

When using the local version of Grafana, you can install the FlightSQL plugin with the grafana-cli CLI or in the Grafana user interface (UI).

Use grafana-cli

Run the following command to install the FlightSQL plugin:

grafana-cli plugins install influxdata-flightsql-datasource

After installing the plugin, you may need to restart your Grafana server.

Use the Grafana UI

  1. In the Grafana UI, navigate to Configuration > Plugins.
  2. Search for and select the FlightSQL plugin.
  3. Click Install.
  1. In your Grafana Cloud instance, navigate to Administration > Plugins.
  2. Search for and select the FlightSQL plugin.
  3. Click Install via grafana.com to navigate to the plugin page.
  4. On the plugin page, click Install plugin.

After a moment, Grafana Cloud completes the plugin installation in your Grafana Cloud instance.

Create a datasource

Which datasource you create depends on which query language you want to use to query InfluxDB Cloud Serverless:

  • To query with SQL, create a FlightSQL datasource.
  • To query with InfluxQL, create an InfluxDB datasource.
  1. In your Grafana user interface (UI), navigate to Data Sources.

  2. Click Add new data source.

  3. Search for and select the FlightSQL plugin.

  4. Provide a name for your datasource.

  5. Add your connection credentials:

    • Host: Provide the host and port of your Flight SQL client. For InfluxDB Cloud Serverless, this is your InfluxDB Cloud Serverless region domain and port 443. For example:

      us-east-1-1.aws.cloud2.influxdata.com:443
      
    • AuthType: Select token.

    • Token: Provide an InfluxDB API token with read access to the buckets you want to query.

    • Require TLS/SSL: Enable this toggle.

  6. Add connection MetaData. InfluxDB Cloud Serverless requires one of the following key-value pairs:

    • Key: database, Value: Bucket name
    • Key: bucket-id, Value: Bucket ID
  7. Click Save & test.

    Grafana Flight SQL datasource

    If successful, click Explore to begin querying InfluxDB with Flight SQL and Grafana.

Map databases and retention policies to buckets

To query InfluxDB Cloud Serverless with InfluxQL, first map database and retention policy (DBRP) combinations to your InfluxDB Cloud buckets. For more information, see Map databases and retention policies to buckets.

  1. In your Grafana user interface (UI), navigate to Data Sources.

  2. Click Add new data source.

  3. Search for and select the InfluxDB core plugin.

  4. Provide a name for your datasource.

  5. Under Query Language, select InfluxQL.

  6. Under HTTP:

  7. Under InfluxDB Details:

    • Database: Provide a database name to query. Use the database name that is mapped to your InfluxBD Cloud bucket.
    • User: Provide an arbitrary string. This credential is ignored when querying InfluxDB Cloud Serverless, but it cannot be empty.
    • Password: Provide an API token with read access to the buckets you want to query.
  8. Click Save & test.

    Grafana InfluxDB datasource for InfluxDB Cloud Serverless

Query InfluxDB with Grafana

After you configure and save a FlightSQL or InfluxDB datasource, use Grafana to build, run, and inspect queries against your InfluxDB bucket.

When working with the InfluxDB SQL implementation, a bucket is equivalent to a database, a measurement is structured as a table, and time, fields, and tags are structured as columns. To learn more, see Query Data.

  1. Click Explore.
  2. In the dropdown, select the saved data source that you want to query.
  3. Use the SQL query form to build your query:
    • FROM: Select the measurement that you want to query.
    • SELECT: Select one or more fields and tags to return as columns in query results. In Grafana, you must specify a time column in the SELECT list.
    • WHERE: To filter the query results, enter a conditional expression.
    • GROUP BY: To GROUP BY one or more fields or tags, enter them as a comma-delimited list. If you include an aggregate function in the SELECT list, then you must include one or more of the queried columns in a GROUP BY or PARTITION BY clause. SQL will return the aggregation for each group or partition.
  4. Click Run query to execute the query.
Grafana Flight SQL datasource query
  1. Click Explore.
  2. In the dropdown, select the InfluxDB data source that you want to query.
  3. Use the InfluxQL query form to build your query:
    • FROM: Select the measurement that you want to query.
    • WHERE: To filter the query results, enter a conditional expression.
    • SELECT: Select fields to query and an aggregate function to apply to each. The aggregate function is applied to each time interval defined in the GROUP BY clause.
    • GROUP BY: By default, Grafana groups data by time to downsample results and improve query performance. You can also add other tags to group by.
  4. Click Run query to execute the query.

To learn about query management and inspection in Grafana, see the Grafana Explore documentation.

Build visualizations with Grafana

For a comprehensive walk-through of creating visualizations with Grafana, see the Grafana documentation.


Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following:

State of the InfluxDB Cloud Serverless documentation

InfluxDB Cloud Serverless documentation is a work in progress.

The new documentation for InfluxDB Cloud Serverless is a work in progress. We are adding new information and content almost daily. Thank you for your patience!

If there is specific information you’re looking for, please submit a documentation issue.

InfluxDB Cloud Serverless