influx
Interact with InfluxDB from the command line
TLDR
Connect to an InfluxDB running on localhost with no credentials
Connect with a specific username (will prompt for a password)
Connect to a specific host
Use a specific database
Execute a given command
Return output in a specific format
SYNOPSIS
influx command [options] [arguments]
The influx command operates using a subcommand pattern. Users specify a primary operation (e.g., query, write, bucket, auth) followed by its specific options and arguments. The influx command itself also accepts global options that affect its overall behavior, such as connection parameters. For InfluxDB 1.x compatibility, it can also launch an InfluxQL shell directly.
PARAMETERS
-h, --help
Display help information for the command or subcommand.
-v, --version
Print the current version of the InfluxDB CLI.
-t, --token <token>
Specify the InfluxDB API token for authentication (primarily InfluxDB 2.x).
-u, --host <url>
Set the URL of the InfluxDB instance (e.g., http://localhost:8086).
-o, --org <name|id>
Specify the organization name or ID to interact with (primarily InfluxDB 2.x).
--active-config <name>
Set the active configuration profile for the CLI, managing multiple connections.
query
Execute Flux or InfluxQL queries against an InfluxDB instance. Accepts -q for a query string or -f for a query file.
write
Write data into an InfluxDB bucket. Supports Line Protocol directly or via files using -f.
bucket
Manage InfluxDB buckets (create, list, delete, update).
auth
Manage InfluxDB API tokens and authentication for InfluxDB 2.x.
setup
Walk through the initial setup process for a fresh InfluxDB 2.x instance.
config
Manage CLI configurations, allowing multiple InfluxDB connections to be saved and activated.
shell
Launch an interactive InfluxQL shell for InfluxDB 1.x compatibility or direct 1.x queries.
DESCRIPTION
The influx command is the official command-line interface (CLI) for InfluxDB, a powerful open-source time-series database. It enables users to interact directly with InfluxDB instances, whether local or remote, to perform a wide range of operations. Through influx, administrators and developers can execute InfluxQL or Flux queries to retrieve and analyze time-series data, write new data points, and manage various database components like organizations, buckets, tasks, and API tokens in InfluxDB 2.x. For InfluxDB 1.x compatibility, it also supports managing databases, users, retention policies, and continuous queries. It's an essential tool for both ad-hoc data exploration and scripting database administration tasks, providing a robust textual interface for managing and interacting with your time-series data. It acts as a client to the InfluxDB HTTP API, offering a convenient way to perform operations that would otherwise require direct API calls.
CAVEATS
The influx command is a client-side tool and requires an active InfluxDB server instance to function. It is crucial to ensure compatibility between the influx CLI version and the InfluxDB server version, particularly when dealing with InfluxDB 1.x versus 2.x, as the CLI's functionalities and default behaviors differ significantly between major versions. Proper authentication (API tokens for InfluxDB 2.x, or user credentials for InfluxDB 1.x) and network connectivity to the InfluxDB host are prerequisites for successful interaction. While powerful, complex data transformations or extensive scripting often benefit from client libraries in programming languages rather than relying solely on the CLI.
INTERACTIVE SHELL (INFLUXQL)
For InfluxDB 1.x or for direct InfluxQL interaction with InfluxDB 2.x (if the 1.x compatibility API is enabled), the influx shell subcommand provides an interactive prompt where users can type and execute InfluxQL queries directly, similar to traditional SQL clients. This mode is particularly useful for ad-hoc data exploration and debugging specific InfluxQL queries.
CONFIGURATION MANAGEMENT
The influx config subcommand allows users to manage multiple connection profiles to different InfluxDB instances. This is especially useful in environments with multiple InfluxDB servers, different user accounts, or varying connection parameters, enabling quick switching between configurations without retyping connection details for each operation.
HISTORY
The influx command-line interface originated alongside the InfluxDB time-series database itself, primarily supporting InfluxDB 1.x versions with an interactive InfluxQL shell and administrative commands. With the advent of InfluxDB 2.x, the CLI underwent a significant re-architecture to adopt a more modular, subcommand-based structure, align with the new organization and bucket concepts, and fully integrate support for the Flux data scripting language. This evolution reflects InfluxData's continuous development of the InfluxDB ecosystem, providing a consistent and powerful tool for managing and interacting with the database across its versions.