Get started querying data
InfluxDB Clustered is currently 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.
InfluxDB Clustered supports multiple query languages:
- SQL: Traditional SQL powered by the Apache Arrow DataFusion query engine. The supported SQL syntax is similar to PostgreSQL.
- InfluxQL: An SQL-like query language designed to query time series data stored in InfluxDB.
This tutorial walks you through the fundamentals of querying data in InfluxDB and focuses on using SQL to query your time series data. The InfluxDB SQL implementation is built using Arrow Flight SQL, a protocol for interacting with SQL databases using the Arrow in-memory format and the Flight RPC framework. It leverages the performance of Apache Arrow with the simplicity of SQL.
Tools to execute queries
InfluxDB Clustered supports many different tools for querying data, including:* Covered in this tutorial
- InfluxDB v3 client libraries
- Flight clients*
- InfluxQL with InfluxDB v1 HTTP API
/api/v2/query not supported
/api/v2/query API endpoint and associated tooling, such as the
influx CLI and InfluxDB v2 client libraries, aren’t supported in InfluxDB Clustered.
SQL query basics
The InfluxDB Clustered SQL implementation is powered by the Apache Arrow DataFusion query engine which provides an SQL syntax similar to PostgreSQL.
This is a brief introduction to writing SQL queries for InfluxDB. For more in-depth details, see Query data with SQL.
InfluxDB SQL queries most commonly include the following clauses:* Required
SELECT: Identify specific fields and tags to query from a measurement or use the wildcard alias (
*) to select all fields and tags from a measurement.
FROM: Identify the measurement to query. If coming from an SQL background, an InfluxDB measurement is the equivalent of a relational table.
WHERE: Only return data that meets defined conditions such as falling within a time range, containing specific tag values, etc.
GROUP BY: Group data into SQL partitions and apply an aggregate or selector function to each group.
Example SQL queries
Select all data in a measurement
SELECT * FROM home
Select all data in a measurement within time bounds
Select a specific field within relative time bounds
SELECT temp FROM home WHERE time >= now() - INTERVAL '1 day'
Select specific fields and tags from a measurement
SELECT temp, room FROM home
Select data based on tag value
SELECT * FROM home WHERE room = 'Kitchen'
Select data based on tag value within time bounds
Downsample data by applying interval-based aggregates
Execute an SQL query
Get started with one of the following tools for querying data stored in an InfluxDB Clustered database:
- InfluxDB v3 client libraries: Use language-specific (Python, Go, etc.) clients to execute queries in your terminal or custom code.
- influx3 CLI: Send queries from your terminal command-line.
- Grafana: Use the FlightSQL Data Source plugin, to query, connect, and visualize data.
For this example, use the following query to select all the data written to the get-started database between
Some examples in this getting started tutorial assume your InfluxDB credentials (URL, organization, and token) are provided by environment variables.
Congratulations! You’ve learned the basics of querying data in InfluxDB with SQL. For a deep dive into all the ways you can query InfluxDB Clustered, see the Query data in InfluxDB section of 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.