Documentation

influxctl query

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

Provide the query in one of the following ways:

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

Important to note

  • This command supports only one query per execution.
  • 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 influxctl connection profile. Default uses 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 flag lets you print the output in other formats. The json format is available for programmatic parsing by other tooling. Default: table.

When using the table format, by default, timestamps are formatted as RFC3339 timestamps. Use the --time-format flag to specify one of the available time formats:

Usage

influxctl query [flags] <QUERY>

Arguments

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

Flags

FlagDescription
--databaseDatabase to query
--enable-system-tablesEnable ability to query system tables
--formatOutput format (table (default) or json)
--languageQuery language (sql (default) or influxql)
--time-formatTime format for table output (rfc3339nano (default) or unixnano)
--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 3 with SQL

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

Query InfluxDB 3 with InfluxQL

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

Query InfluxDB 3 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 3 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 3 and return results with Unix nanosecond timestamps

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

View example table-formatted results

Query InfluxDB 3 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'"

Query data from InfluxDB 3 system tables

You must use SQL to query InfluxDB 3 system tables.

Querying system tables can impact the overall performance of your InfluxDB cluster. System tables are not part of InfluxDB’s stable API and are subject to change.

influxctl query \
  --enable-system-tables \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
"SELECT * FROM system.tables WHERE table_name = '
TABLE_NAME
'"
influxctl query \
  --enable-system-tables \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
/path/to/query.sql
cat ./query.sql | influxctl query \
  --enable-system-tables \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
-

View command updates


Was this page helpful?

Thank you for your feedback!


New in InfluxDB 3.5

Key enhancements in InfluxDB 3.5 and the InfluxDB 3 Explorer 1.3.

See the Blog Post

InfluxDB 3.5 is now available for both Core and Enterprise, introducing custom plugin repository support, enhanced operational visibility with queryable CLI parameters and manual node management, stronger security controls, and general performance improvements.

InfluxDB 3 Explorer 1.3 brings powerful new capabilities including Dashboards (beta) for saving and organizing your favorite queries, and cache querying for instant access to Last Value and Distinct Value cachesβ€”making Explorer a more comprehensive workspace for time series monitoring and analysis.

For more information, check out:

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On November 3, 2025, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2