Use the influxctl CLI to query data
Use the influxctl query
command
to query data in InfluxDB Cloud Dedicated 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 theinfluxctl
connection profile or the--token
command flag. -
Database name: The name of the database to query. By default, this uses the
database
setting from theinfluxctl
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 \
--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 databaseDATABASE_NAME
: Name of the database to query
Output format
The influxctl query
command supports the following output formats:
table
(default)json
Use the --format
flag to specify the output format:
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:
rfc3339nano
: (Default) RFC3339Nano-formatted timestamp–for example:2024-01-01T00:00:00.000000000Z
unixnano
: Unix nanosecond timestamp
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.