Documentation

influxctl query

Limited availability

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.

The influxctl query command queries data from InfluxDB Clustered using SQL and prints results as a table or JSON.

Provide the SQL query in one of the following ways:

  • a string on the command line
  • a path to a file that contains the query
  • a single dash (-) to read the query from stdin

Important to note

  • This command supports only one query per execution.
  • This command supports only SQL queries; not InfluxQL.
  • This command is not meant to be a full, feature-rich query tool. It’s meant for debug, triage, and basic data exploration.

InfluxDB connection configuration

Your InfluxDB cluster host and port are configured in your in your influxctl connection profile. Default is TLS and port 443. You can set a default database and token to use for the query and write commands in your connection profile or pass them with the command using the --database and --token flags. Command line flags override settings in the connection profile.

Output format

The --format option lets you print the output in other formats. Default is ’table’ format, but the ‘json’ format is available for programmatic parsing by other tooling.

Usage

influxctl query [flags] <QUERY>

Arguments

ArgumentDescription
QUERYSQL query to execute (command line string, path to file, or - to read from stdin)

Flags

FlagDescription
--databaseDatabase to query
--formatOutput format (table (default) or json)
--tokenDatabase token with read permissions on the queried database
-h--helpOutput command help

Examples

In the examples below, replace the following:

  • DATABASE_TOKEN: Database token with read access to the queried database
  • DATABASE_NAME: Name of the database to query

Query InfluxDB v3 and return results in table format

influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
"SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' LIMIT 5"
influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
/path/to/query.sql
cat ./query.sql | influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
-

View example table-formatted results

Query InfluxDB v3 and return results in JSON format

influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
--format json \ "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' LIMIT 5"
influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
--format json \ /path/to/query.sql
cat ./query.sql | influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
--format json \ -

View example JSON-formatted results

Query InfluxDB v3 using credentials from the connection profile

The following example uses the database and token defined in the default connection profile.

influxctl query "SELECT * FROM home WHERE time >= '2022-01-01T08:00:00Z' LIMIT 5"

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: