Documentation

Use the influxctl CLI to query data

Use the influxctl query command to query data in InfluxDB Clustered with SQL or InfluxQL.

Provide the following with your command:

  • Database token: A database token with read permissions on the queried database. By default, this uses the database setting from the influxctl connection profile or the --token command flag.

  • Database name: The name of the database to query. By default, this uses the database setting from the influxctl connection profile or the --database command flag.

  • Query language (Optional): The query language of the query. Use the --language flag to specify one of the following query languages:

    • sql (default)
    • influxql
  • Query: SQL or InfluxQL query to execute. Pass the 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
influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
"SELECT * FROM home"
influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
/path/to/query.sql
cat ./query.sql | influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
-
influxctl query \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
--language influxql \ "SELECT * FROM home"
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 \ -

Replace the following:

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

Query timeouts

The influxctl --timeout global flag sets the maximum duration for API calls, including query requests. If a query takes longer than the specified timeout, the operation will be canceled.

Timeout examples

Use different timeout values based on your query type:

# Shorter timeout for testing dashboard queries (10 seconds)
influxctl query \
  --timeout 10s \
  --token 
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
"SELECT * FROM sensors WHERE time >= now() - INTERVAL '1 hour' LIMIT 100" # Longer timeout for analytical queries (5 minutes) influxctl query \ --timeout 300s \ --token
DATABASE_TOKEN
\
--database
DATABASE_NAME
\
"SELECT room, AVG(temperature) FROM sensors WHERE time >= now() - INTERVAL '30 days' GROUP BY room"

For guidance on selecting appropriate timeout values, see Query timeout best practices.

Output format

The influxctl query command supports the following output formats:

  • table (default)
  • json

Use the --format flag to specify the output format:

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

View example table-formatted results

View example JSON-formatted results

Timestamp format

When using the table output format, you can specify which of the following timestamp formats to use to display timestamp values in the query results:

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

View example results with Unix nanosecond timestamps


Was this page helpful?

Thank you for your feedback!


New in InfluxDB 3.6

Key enhancements in InfluxDB 3.6 and the InfluxDB 3 Explorer 1.4.

See the Blog Post

InfluxDB 3.6 is now available for both Core and Enterprise. This release introduces the 1.4 update to InfluxDB 3 Explorer, featuring the beta launch of Ask AI, along with new capabilities for simple startup and expanded functionality in the Processing Engine.

For more information, check out:

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On February 3, 2026, 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