Use Grafana to query and visualize data
Use Grafana to query and visualize data stored in InfluxDB Cloud Serverless.
[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.
- Install Grafana or login to Grafana Cloud
- InfluxDB data source
- Create an InfluxDB data source
- Query InfluxDB with Grafana
- Build visualizations with Grafana
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.
InfluxDB data source
The InfluxDB data source plugin is included in the Grafana core distribution. Use the plugin to query and visualize data stored in InfluxDB Cloud Serverless with both InfluxQL and SQL.
Grafana 10.3+
The instructions below are for Grafana 10.3+ which introduced the newest version of the InfluxDB core plugin. The updated plugin includes SQL support for InfluxDB v3-based products such as InfluxDB Cloud Serverless.
Create an InfluxDB data source
Which data source you create depends on which query language you want to use to query InfluxDB Cloud Serverless:
- In your Grafana user interface (UI), navigate to Data Sources.
- Click Add new data source.
- Search for and select the InfluxDB plugin.
- Provide a name for your data source.
- Under Query Language, select either SQL or InfluxQL:
When creating an InfluxDB data source that uses SQL to query data:
-
Under HTTP:
-
URL: Provide your InfluxDB Cloud Serverless region URL using the HTTPS protocol:
https://cloud2.influxdata.com
-
-
Under InfluxDB Details:
- Database: Provide a default bucket name to query. In InfluxDB Cloud Serverless, a bucket functions as a database.
- Token: Provide an API token with read access to the buckets you want to query.
-
Click Save & test.
When creating an InfluxDB data source that uses InfluxQL to query data:
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.
-
Under HTTP:
-
URL: Provide your InfluxDB Cloud Serverless region URL using the HTTPS protocol:
https://cloud2.influxdata.com
-
-
Under InfluxDB Details:
-
Database: Provide a database name to query. Use the database name that is mapped to your InfluxBD 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.
-
HTTP Method: Choose one of the available HTTP request methods to use when querying data:
- POST (Recommended)
- GET
-
-
Click Save & test.
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.
-
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 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 thetime
column to correctly graph time series data. -
Optional: Toggle filter to generate WHERE clause statements.
- WHERE: Configure condition expressions to include in the
WHERE
clause.
- WHERE: Configure condition expressions to include in the
-
Optional: Toggle group to generate GROUP BY clause statements.
- GROUP BY: Select columns to group by. If you include an aggregation function in the SELECT list, you must group by one or more of the queried columns. SQL returns the aggregation for each group.
-
Recommended: Toggle order to generate ORDER BY clause statements.
- ORDER BY: Select columns to sort by. You can sort by time and multiple fields or tags. To sort in descending order, select DESC.
-
-
Recommended: Change format to Time series.
- Use the Format dropdown to change the format of the query results. For example, to visualize the query results as a time series, select Time series.
-
Click Run query to execute the query.
- Click Explore.
- In the dropdown, select the InfluxDB data source that you want to query.
- 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.
- 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!
Support and feedback
Thank you for being part of our community! We welcome and encourage your feedback and bug reports for InfluxDB and this documentation. To find support, use the following resources:
Customers with an annual or support contract can contact InfluxData Support.