Merge pull request #6002 from influxdata/5949-add-api-reference-examples-to-influxdb3

Adding adequate CLI examples for creating triggers
pull/6075/head^2
Jameelah Mercer 2025-05-19 10:43:43 -07:00 committed by GitHub
commit 2cd8687246
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 353 additions and 212 deletions

View File

@ -0,0 +1,56 @@
---
title: Revoke a database token
description: >
Use the [`influxctl token revoke` command](/influxdb3/clustered/reference/cli/influxctl/token/revoke/)
to revoke a token from your InfluxDB cluster and disable all
permissions associated with the token.
Provide the ID of the token you want to revoke.
menu:
influxdb3_clustered:
parent: Database tokens
weight: 203
list_code_example: |
```sh
influxctl token revoke <TOKEN_ID>
```
aliases:
- /influxdb3/clustered/admin/tokens/delete/
- /influxdb3/clustered/admin/tokens/database/delete/
---
Use the [`influxctl token revoke` command](/influxdb3/clustered/reference/cli/influxctl/token/revoke/)
to revoke a database token from your {{< product-name omit=" Clustered" >}} cluster and disable
all permissions associated with the token.
1. If you haven't already, [download and install the `influxctl` CLI](/influxdb3/clustered/reference/cli/influxctl/#download-and-install-influxctl).
2. Run the [`influxctl token list` command](/influxdb3/clustered/reference/cli/influxctl/token/list)
to output tokens with their IDs.
Copy the **token ID** of the token you want to delete.
```sh
influxctl token list
```
3. Run the `influxctl token revoke` command and provide the following:
- Token ID to revoke
4. Confirm that you want to revoke the token.
{{% code-placeholders "TOKEN_ID" %}}
```sh
influxctl token revoke TOKEN_ID
```
{{% /code-placeholders %}}
> [!Warning]
> #### Revoking a token is immediate and cannot be undone
>
> Revoking a database token is a destructive action that takes place immediately
> and cannot be undone.
>
> #### Rotate revoked tokens
>
> After revoking a database token, any clients using the revoked token need to
> be updated with a new database token to continue to interact with your
> {{% product-name omit=" Clustered" %}} cluster.

View File

@ -1,15 +0,0 @@
---
title: influxdb3 create plugin
description: >
The `influxdb3 create plugin` command creates a new processing engine plugin.
menu:
influxdb3_core:
parent: influxdb3 create
name: influxdb3 create plugin
weight: 400
source: /shared/influxdb3-cli/create/plugin.md
---
<!--
The content of this file is at content/shared/influxdb3-cli/create/plugin.md
-->

View File

@ -1,15 +0,0 @@
---
title: influxdb3 delete plugin
description: >
The `influxdb3 delete plugin` command deletes a processing engine plugin.
menu:
influxdb3_core:
parent: influxdb3 delete
name: influxdb3 delete plugin
weight: 400
source: /shared/influxdb3-cli/delete/last_cache.md
---
<!--
The content of this file is at content/shared/influxdb3-cli/delete/plugin.md
-->

View File

@ -1,15 +0,0 @@
---
title: influxdb3 create plugin
description: >
The `influxdb3 create plugin` command creates a new processing engine plugin.
menu:
influxdb3_enterprise:
parent: influxdb3 create
name: influxdb3 create plugin
weight: 400
source: /shared/influxdb3-cli/create/plugin.md
---
<!--
The content of this file is at content/shared/influxdb3-cli/create/plugin.md
-->

View File

@ -1,15 +0,0 @@
---
title: influxdb3 delete plugin
description: >
The `influxdb3 delete plugin` command deletes a processing engine plugin.
menu:
influxdb3_enterprise:
parent: influxdb3 delete
name: influxdb3 delete plugin
weight: 400
source: /shared/influxdb3-cli/delete/last_cache.md
---
<!--
The content of this file is at content/shared/influxdb3-cli/delete/plugin.md
-->

View File

@ -18,7 +18,6 @@ influxdb3 create <SUBCOMMAND>
| [file_index](/influxdb3/version/reference/cli/influxdb3/create/file_index/) | Create a new file index for a database or table |
| [last_cache](/influxdb3/version/reference/cli/influxdb3/create/last_cache/) | Create a new last value cache |
| [distinct_cache](/influxdb3/version/reference/cli/influxdb3/create/distinct_cache/) | Create a new distinct value cache |
| [plugin](/influxdb3/version/reference/cli/influxdb3/create/plugin/) | Create a new processing engine plugin |
| [table](/influxdb3/version/reference/cli/influxdb3/create/table/) | Create a new table in a database |
| [token](/influxdb3/version/reference/cli/influxdb3/create/token/) | Create a new authentication token |
| [trigger](/influxdb3/version/reference/cli/influxdb3/create/trigger/) | Create a new trigger for the processing engine |

View File

@ -1,5 +1,6 @@
The `influxdb3 create database` command creates a new database in your {{< product-name >}} instance.
The `influxdb3 create database` command creates a new database.
Provide a database name and, optionally, specify connection settings and authentication credentials using flags or environment variables.
## Usage
@ -11,11 +12,10 @@ influxdb3 create database [OPTIONS] <DATABASE_NAME>
## Arguments
- **DATABASE_NAME**: The name of the database to create.
Valid database names are alphanumeric and start with a letter or number.
Dashes (`-`) and underscores (`_`) are allowed.
- **`DATABASE_NAME`**: The name of the database to create. Valid database names are alphanumeric and start with a letter or number. Dashes (-) and underscores (_) are allowed.
Environment variable: `INFLUXDB3_DATABASE_NAME`
You can also set the database name using the `INFLUXDB3_DATABASE_NAME` environment variable.
## Options
@ -29,7 +29,7 @@ influxdb3 create database [OPTIONS] <DATABASE_NAME>
### Option environment variables
You can use the following environment variables to set command options:
You can use the following environment variables instead of providing CLI options directly:
| Environment Variable | Option |
| :------------------------ | :----------- |
@ -38,11 +38,9 @@ You can use the following environment variables to set command options:
## Examples
- [Create a new database](#create-a-new-database)
- [Create a new database while specifying the token inline](#create-a-new-database-while-specifying-the-token-inline)
In the examples below, replace the following:
The following examples show how to create a database.
In your commands replace the following:
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Database name
- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}:
@ -50,7 +48,9 @@ In the examples below, replace the following:
{{% code-placeholders "DATABASE_NAME|AUTH_TOKEN" %}}
### Create a new database
### Create a database (default)
Creates a database using settings from environment variables and defaults.
<!--pytest.mark.skip-->
@ -58,7 +58,10 @@ In the examples below, replace the following:
influxdb3 create database DATABASE_NAME
```
### Create a new database while specifying the token inline
### Create a database with an authentication token
Creates a database using the specified arguments.
Flags override their associated environment variables.
<!--pytest.mark.skip-->

View File

@ -1,5 +1,6 @@
The `influxdb3 create distinct_cache` command creates a new distinct value cache for a specific table and column set in your {{< product-name >}} instance.
The `influxdb3 create distinct_cache` command creates a new distinct value cache.
Use this command to configure a cache that tracks unique values in specified columns. You must provide the database, token, table, and columns. Optionally, you can specify a name for the cache.
## Usage
@ -16,10 +17,9 @@ influxdb3 create distinct_cache [OPTIONS] \
## Arguments
- **CACHE_NAME**: _(Optional)_ Name for the cache.
If not provided, the command automatically generates a name.
- **`CACHE_NAME`**: _(Optional)_ A name to assign to the cache. If omitted, the CLI generates a name automatically.
## Options
## Options
| Option | | Description |
| :----- | :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@ -52,4 +52,69 @@ You can use the following environment variables to set command options:
| `INFLUXDB3_DATABASE_NAME` | `--database` |
| `INFLUXDB3_AUTH_TOKEN` | `--token` |
<!-- TODO: GET EXAMPLES -->
## Prerequisites
Before creating a distinct value cache, make sure you:
1. [Create a database](/influxdb3/version/reference/cli/influxdb3/create/database/)
2. [Create a table](/influxdb3/version/reference/cli/influxdb3/create/table/) that includes the columns you want to cache
3. Have a valid authentication token
## Examples
Before running the following commands, replace the placeholder values with your own:
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
The database name
- {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}}:
The name of the table to cache values from
- {{% code-placeholder-key %}}`CACHE_NAME`{{% /code-placeholder-key %}}:
The name of the distinct value cache to create
- {{% code-placeholder-key %}}`COLUMN_NAME`{{% /code-placeholder-key %}}: The column to
cache distinct values from
You can also set environment variables (such as `INFLUXDB3_AUTH_TOKEN`) instead of passing options inline.
{{% code-placeholders "(DATABASE|TABLE|COLUMN|CACHE)_NAME" %}}
### Create a distinct cache for one column
Track unique values from a single column. This setup is useful for testing or simple use cases.
<!--pytest.mark.skip-->
```bash
influxdb3 create distinct_cache \
--database DATABASE_NAME \
--table TABLE_NAME \
--column COLUMN_NAME \
CACHE_NAME
```
### Create a hierarchical cache with constraints
Create a distinct value cache for multiple columns. The following example tracks unique combinations of `room` and `sensor_id`, and sets limits on the number of entries and their maximum age.
<!--pytest.mark.skip-->
```bash
influxdb3 create distinct_cache \
--database my_test_db \
--table my_sensor_table \
--columns room,sensor_id \
--max-cardinality 1000 \
--max-age 30d \
my_sensor_distinct_cache
```
{{% /code-placeholders %}}
## Common pitfalls
- `--column` is not valid. Use `--columns`.
- Tokens must be included explicitly unless set via `INFLUXDB3_AUTH_TOKEN`
- Table and column names must already exist or be recognized by the engine

View File

@ -1,18 +1,23 @@
The `influxdb3 create last_cache` command creates a new last value cache.
The `influxdb3 create last_cache` command creates a last value cache, which stores the most recent values for specified columns in a table. Use this to efficiently retrieve the latest values based on key column combinations.
## Usage
{{% code-placeholders "DATABASE_NAME|TABLE_NAME|AUTH_TOKEN|CACHE_NAME" %}}
<!--pytest.mark.skip-->
```bash
influxdb3 create last_cache [OPTIONS] --database <DATABASE_NAME> --table <TABLE> [CACHE_NAME]
influxdb3 create last_cache [OPTIONS] \
--database DATABASE_NAME \
--table TABLE_NAME \
--token AUTH_TOKEN \
CACHE_NAME
```
{{% /code-placeholders %}}
## Arguments
- **CACHE_NAME**: _(Optional)_ Name for the cache.
If not provided, the command automatically generates a name.
- **CACHE_NAME**: _(Optional)_ Name for the cache. If omitted, InfluxDB automatically generates one.
## Options
@ -32,7 +37,7 @@ influxdb3 create last_cache [OPTIONS] --database <DATABASE_NAME> --table <TABLE>
### Option environment variables
You can use the following environment variables to set command options:
You can use the following environment variables as substitutes for CLI options:
| Environment Variable | Option |
| :------------------------ | :----------- |
@ -40,4 +45,59 @@ You can use the following environment variables to set command options:
| `INFLUXDB3_DATABASE_NAME` | `--database` |
| `INFLUXDB3_AUTH_TOKEN` | `--token` |
<!-- TODO: GET EXAMPLES -->
## Prerequisites
Before creating a last value cache, ensure youve done the following:
- Create a [database](/influxdb3/version/reference/cli/influxdb3/create/database/).
- Create a [table](/influxdb3/version/reference/cli/influxdb3/create/table/) with the columns you want to cache.
- Have a valid authentication token.
## Examples
A last value cache stores the most recent values from specified columns in a table.
### Create a basic last value cache for one column
The following example shows how to track the most recent value for a single key (the last temperature for each room):
<!--pytest.mark.skip-->
```bash
influxdb3 create last_cache \
--database DATABASE_NAME \
--table my_sensor_table \
--token AUTH_TOKEN \
--key-columns room \
--value-columns temp \
my_temp_cache
```
### Create a last value cache with multiple keys and values
The following example shows how to:
- Use multiple columns as a composite key
- Track several values per key combination
- Set a cache entry limit with `--count`
- Configure automatic expiry with `--ttl`
<!--pytest.mark.skip-->
```bash
influxdb3 create last_cache \
--database DATABASE_NAME \
--table my_sensor_table \
--token AUTH_TOKEN \
--key-columns room,sensor_id \
--value-columns temp,hum \
--count 10 \
--ttl 1h \
my_sensor_cache
```
## Usage notes
- Define the table schema to include all specified key and value columns.
- Pass tokens using `--token`, unless you've set one through an environment variable.
- Specify `--count` and `--ttl` to override the defaults; otherwise, the system uses default values.

View File

@ -1,45 +0,0 @@
The `influxdb3 create plugin` command creates a new processing engine plugin.
## Usage
<!--pytest.mark.skip-->
```bash
influxdb3 create plugin [OPTIONS] \
--database <DATABASE_NAME> \
--token <AUTH_TOKEN> \
--filename <PLUGIN_FILENAME> \
--entry-point <FUNCTION_NAME> \
<PLUGIN_NAME>
```
## Arguments
- **PLUGIN_NAME**: The name of the plugin to create.
## Options
| Option | | Description |
| :----- | :-------------- | :--------------------------------------------------------------------------------------- |
| `-H` | `--host` | Host URL of the running {{< product-name >}} server (default is `http://127.0.0.1:8181`) |
| `-d` | `--database` | _({{< req >}})_ Name of the database to operate on |
| | `--token` | _({{< req >}})_ Authentication token |
| | `--filename` | _({{< req >}})_ Name of the plugin Python file in the plugin directory |
| | `--entry-point` | _({{< req >}})_ Entry point function name for the plugin |
| | `--plugin-type` | Type of trigger the plugin processes (default is `wal_rows`) |
| | `--tls-ca` | Path to a custom TLS certificate authority (for testing or self-signed certificates) |
| `-h` | `--help` | Print help information |
| | `--help-all` | Print detailed help information |
### Option environment variables
You can use the following environment variables to set command options:
| Environment Variable | Option |
| :------------------------ | :----------- |
| `INFLUXDB3_HOST_URL` | `--host` |
| `INFLUXDB3_DATABASE_NAME` | `--database` |
| `INFLUXDB3_AUTH_TOKEN` | `--token` |
<!-- TODO: GET EXAMPLES -->

View File

@ -1,5 +1,10 @@
The `influxdb3 create table` command creates a table in a database.
The `influxdb3 create table` command creates a new table in a specified database. Tables must include at least one tag column and can optionally include field columns with defined data types.
> [!Note]
> InfluxDB automatically creates tables when you write line protocol data. Use this command
> only if you need to define a custom schema or apply a custom partition template before
> writing data.
## Usage
@ -39,7 +44,7 @@ influxdb3 create table [OPTIONS] \
### Option environment variables
You can use the following environment variables to set command options:
You can use the following environment variables to set options instead of passing them via CLI flags:
| Environment Variable | Option |
| :------------------------ | :----------- |
@ -49,21 +54,20 @@ You can use the following environment variables to set command options:
## Examples
- [Create a table](#create-a-table)
- [Create a table with tag and field columns](#create-a-table-with-tag-and-field-columns)
In the examples below, replace the following:
In the following examples, replace each placeholder with your actual values:
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Database name
The database name
- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}:
Authentication token
- {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}}:
Table name
A name for the new table
{{% code-placeholders "(DATABASE|TABLE)_NAME" %}}
{{% code-placeholders "DATABASE_NAME|TABLE_NAME|AUTH_TOKEN" %}}
### Create a table
### Create an empty table
<!--pytest.mark.skip-->
```bash
influxdb3 create table \
@ -86,4 +90,31 @@ influxdb3 create table \
TABLE_NAME
```
### Verification
Use the `SHOW TABLES` query to verify that the table was created successfully:
<!--pytest.mark.skip-->
```bash
influxdb3 query \
--database my_test_db \
--token AUTH_TOKEN \
"SHOW TABLES"
Example output:
+---------------+--------------------+----------------------------+------------+
| table_catalog | table_schema | table_name | table_type |
+---------------+--------------------+----------------------------+------------+
| public | iox | my_sensor_table | BASE TABLE |
| public | system | distinct_caches | BASE TABLE |
| public | system | last_caches | BASE TABLE |
| public | system | parquet_files | BASE TABLE |
+---------------+--------------------+----------------------------+------------+
```
>[!Note]
> `SHOW TABLES` is an SQL query. It isn't supported in InfluxQL.
{{% /code-placeholders %}}

View File

@ -1,12 +1,14 @@
The `influxdb3 create token` command creates a new authentication token. This returns the raw token string. Use it to authenticate future CLI commands and API requests.
The `influxdb3 create token` command creates a new authentication token.
> [!Important]
> InfluxDB displays the raw token string only once. Be sure to copy and securely store it.
## Usage
<!--pytest.mark.skip-->
```bash
influxdb3 create token <COMMAND> [OPTIONS]
influxdb3 create token <SUBCOMMAND>
```
## Commands
@ -18,15 +20,46 @@ influxdb3 create token <COMMAND> [OPTIONS]
## Options
| Option | | Description |
| :----- | :----------- | :------------------------------ |
| `-h` | `--help` | Print help information |
| | `--help-all` | Print detailed help information |
| Option | | Description |
| :----- | :------- | :--------------------- |
| |`--admin`| Create an admin token |
| `-h` | `--help` | Print help information |
## Examples
### Create an admin token
<!--pytest.mark.skip-->
```bash
influxdb3 create token --admin
```
```
The output is the raw token string you can use to authenticate future CLI commands and API requests.
For CLI commands, use the `--token` option or the `INFLUXDB3_AUTH_TOKEN` environment variable to pass the token string.
### Use the token to create a database
{{% code-placeholders "YOUR_ADMIN_TOKEN|DATABASE_NAME" %}}
<!--pytest.mark.skip-->
```bash
influxdb3 create database \
--token ADMIN_TOKEN \
DATABASE_NAME
```
{{% /code-placeholders %}}
Replace the following:
- {{% code-placeholder-key %}}`ADMIN_TOKEN`{{% /code-placeholder-key %}}: Your InfluxDB admin token
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: Name for your new database
> [!Note]
> Set the token as an environment variable to simplify repeated CLI commands:
>
> ```bash
> export INFLUXDB3_AUTH_TOKEN=YOUR_ADMIN_TOKEN
> ```

View File

@ -10,7 +10,6 @@ processing engine.
influxdb3 create trigger [OPTIONS] \
--database <DATABASE_NAME> \
--token <AUTH_TOKEN> \
--plugin <PLUGIN_NAME> \
--trigger-spec <TRIGGER_SPECIFICATION> \
<TRIGGER_NAME>
```
@ -26,7 +25,6 @@ influxdb3 create trigger [OPTIONS] \
| `-H` | `--host` | Host URL of the running {{< product-name >}} server (default is `http://127.0.0.1:8181`) |
| `-d` | `--database` | _({{< req >}})_ Name of the database to operate on |
| | `--token` | _({{< req >}})_ Authentication token |
| | `--plugin` | Plugin to execute when the trigger fires |
| | `--trigger-spec` | Trigger specification--for example `table:<TABLE_NAME>` or `all_tables` |
| | `--disabled` | Create the trigger in disabled state |
| | `--tls-ca` | Path to a custom TLS certificate authority (for testing or self-signed certificates) |
@ -43,4 +41,66 @@ You can use the following environment variables to set command options:
| `INFLUXDB3_DATABASE_NAME` | `--database` |
| `INFLUXDB3_AUTH_TOKEN` | `--token` |
<!-- TODO: GET EXAMPLES -->
## Examples
The following examples show how to use the `influxdb3 create trigger` command to create triggers in different scenarios.
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: Database name
- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}:
Authentication token
- {{% code-placeholder-key %}}`TRIGGER_NAME`{{% /code-placeholder-key %}}:
Name of the trigger to create
- {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}}:
Name of the table to trigger on
{{% code-placeholders "(DATABASE|TRIGGER)_NAME|AUTH_TOKEN|TABLE_NAME" %}}
### Create a trigger for a specific table
Create a trigger that processes data from a specific table.
<!--pytest.mark.skip-->
```bash
influxdb3 create trigger \
--database DATABASE_NAME \
--token AUTH_TOKEN \
--trigger-spec table:TABLE_NAME \
TRIGGER_NAME
```
### Create a trigger for all tables
Create a trigger that applies to all tables in the specified database.
<!--pytest.mark.skip-->
```bash
influxdb3 create trigger \
--database DATABASE_NAME \
--token AUTH_TOKEN \
--trigger-spec all_tables \
TRIGGER_NAME
```
This is useful when you want a trigger to apply to any table in the database, regardless of name.
### Create a disabled trigger
Create a trigger in a disabled state.
<!--pytest.mark.skip-->
```bash
influxdb3 create trigger \
--disabled \
--database DATABASE_NAME \
--token AUTH_TOKEN \
--trigger-spec table:TABLE_NAME \
TRIGGER_NAME
```
Creating a trigger in a disabled state prevents it from running immediately. You can enable it later when you're ready to activate it.
{{% /code-placeholders %}}

View File

@ -11,7 +11,7 @@ influxdb3 delete database [OPTIONS] <DATABASE_NAME>
## Arguments
- **DATABASE_NAME**: The name of the database to delete.
- **DATABASE_NAME**: The name of the database to delete. Valid database names are alphanumeric and start with a letter or number. Dashes (`-`) and underscores (`_`) are allowed.
Environment variable: `INFLUXDB3_DATABASE_NAME`

View File

@ -1,61 +0,0 @@
The `influxdb3 delete plugin` command deletes a processing engine plugin.
## Usage
<!--pytest.mark.skip-->
```bash
influxdb3 delete plugin [OPTIONS] --database <DATABASE_NAME> <PLUGIN_NAME>
```
## Arguments
- **PLUGIN_NAME**: The name of the plugin to delete.
## Options
| Option | | Description |
| :----- | :----------- | :--------------------------------------------------------------------------------------- |
| `-H` | `--host` | Host URL of the running {{< product-name >}} server (default is `http://127.0.0.1:8181`) |
| `-d` | `--database` | _({{< req >}})_ Name of the database to operate on |
| | `--token` | _({{< req >}})_ Authentication token |
| | `--tls-ca` | Path to a custom TLS certificate authority (for testing or self-signed certificates) |
| `-h` | `--help` | Print help information |
| | `--help-all` | Print detailed help information |
### Option environment variables
You can use the following environment variables to set command options:
| Environment Variable | Option |
| :------------------------ | :----------- |
| `INFLUXDB3_HOST_URL` | `--host` |
| `INFLUXDB3_DATABASE_NAME` | `--database` |
| `INFLUXDB3_AUTH_TOKEN` | `--token` |
## Examples
### Delete a plugin
{{% code-placeholders "(DATABASE|PLUGIN)_NAME|AUTH_TOKEN" %}}
<!--pytest.mark.skip-->
```bash
influxdb3 delete plugin \
--database DATABASE_NAME \
--token AUTH_TOKEN \
PLUGIN_NAME
```
{{% /code-placeholders %}}
In the example above, replace the following:
- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Database name
- {{% code-placeholder-key %}}`AUTH_TOKEN`{{% /code-placeholder-key %}}:
Authentication token
- {{% code-placeholder-key %}}`PLUGIN_NAME`{{% /code-placeholder-key %}}:
Name of the plugin to delete