Skip to content

Adding adequate CLI examples for creating triggers #6002

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 61 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
e481e68
updating database create for consistency
MeelahMe Apr 18, 2025
0c85184
Adding distinct cache value example
MeelahMe Apr 18, 2025
4746e6e
Adding a create last value cache example
MeelahMe Apr 18, 2025
22c9fc4
Adding a create plugin example
MeelahMe Apr 18, 2025
4f11fc1
adding a creating token example
MeelahMe Apr 18, 2025
4199554
Update content/shared/influxdb3-cli/create/token.md
MeelahMe Apr 18, 2025
d72eccd
Update content/shared/influxdb3-cli/create/token.md
MeelahMe Apr 18, 2025
7d6d7f1
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe Apr 30, 2025
07aded0
Remove plugin.md from create CLI commands
MeelahMe Apr 30, 2025
481575e
Remove plugin.md from delete CLI commands
MeelahMe Apr 30, 2025
98d8d6e
chore(cli): remove plugin.md files and references from create/delete …
MeelahMe Apr 30, 2025
dfd1a9c
chore(cli): remove create plugin.md from enterprise CLI reference
MeelahMe Apr 30, 2025
b16ea65
chore(cli): remove delete plugin.md from enterprise CLI reference
MeelahMe Apr 30, 2025
958e0a8
docs: revise create trigger examples for clarity and accuracy
MeelahMe May 1, 2025
289c24e
docs(cli): fix last_cache example flags and clarify placeholder keys
MeelahMe May 1, 2025
81d8863
docs(cli): correcting trigger disable example
MeelahMe May 1, 2025
1569829
Update content/shared/influxdb3-cli/create/distinct_cache.md
MeelahMe May 1, 2025
87cb056
docs(cli): updated and add tested examples and setup guidance for cr…
MeelahMe May 1, 2025
88ec6af
docs(cli): update table guide with query verification example
MeelahMe May 1, 2025
85310e1
docs: add examples and clarify usage for token, distinct_cache, and l…
MeelahMe May 1, 2025
b3be9de
docs(cli): minor updates to examples
MeelahMe May 1, 2025
f592009
Update content/shared/influxdb3-cli/create/distinct_cache.md
MeelahMe May 1, 2025
e659a0b
Update content/shared/influxdb3-cli/create/distinct_cache.md
MeelahMe May 1, 2025
b71dd9a
chore(cli): remove deprecated delete plugin reference
MeelahMe May 1, 2025
46a4d35
Merge branch '5949-add-api-reference-examples-to-influxdb3' of github…
MeelahMe May 1, 2025
e9bcb06
Update content/shared/influxdb3-cli/create/last_cache.md
MeelahMe May 1, 2025
dedf9ca
chore(cli): removing numbered list
MeelahMe May 2, 2025
eecde07
Merge branch '5949-add-api-reference-examples-to-influxdb3' of github…
MeelahMe May 2, 2025
38a9aaf
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 2, 2025
0f853d0
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 5, 2025
5ee9686
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 6, 2025
8988fb6
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 12, 2025
07c8b95
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 13, 2025
386cfc2
docs(cli): improve create database docs for clarity and style to data…
MeelahMe May 13, 2025
8f8bf55
Merge branch '5949-add-api-reference-examples-to-influxdb3' of github…
MeelahMe May 13, 2025
e6d8838
docs(cli): improve distinct_cache example section and placeholder gui…
MeelahMe May 13, 2025
994e848
WIP: update format
MeelahMe May 15, 2025
663cfc9
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 15, 2025
0cbfade
revising structure
MeelahMe May 15, 2025
5a843f5
docs(cli): improve distinct_cache structure
MeelahMe May 15, 2025
18a4413
docs(cli): add editable placeholders for database, table, and token i…
MeelahMe May 15, 2025
94b4228
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 16, 2025
0f8945f
Merge branch 'master' into 5949-add-api-reference-examples-to-influxdb3
MeelahMe May 16, 2025
8847d67
Update database.md
MeelahMe May 16, 2025
02c3a8b
Update revoke 2.md
MeelahMe May 16, 2025
b460338
Update database.md
MeelahMe May 16, 2025
21588fe
Update database.md
MeelahMe May 16, 2025
3edf4e7
Update database.md
MeelahMe May 16, 2025
9834fab
Update distinct_cache.md
MeelahMe May 16, 2025
dd8369b
Update last_cache.md
MeelahMe May 16, 2025
df24a22
Update last_cache.md
MeelahMe May 16, 2025
2ae9d67
Update table.md
MeelahMe May 16, 2025
af99904
Update table.md
MeelahMe May 16, 2025
2c3b3f8
Update table.md
MeelahMe May 16, 2025
7a39062
Update table.md
MeelahMe May 16, 2025
3a39a92
Update token.md
MeelahMe May 16, 2025
ef239ef
Update token.md
MeelahMe May 16, 2025
a2145f0
Update trigger.md
MeelahMe May 16, 2025
cf87936
Update trigger.md
MeelahMe May 16, 2025
6917097
Update trigger.md
MeelahMe May 16, 2025
7f1a3b6
Update trigger.md
MeelahMe May 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion content/shared/influxdb3-cli/create/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
78 changes: 76 additions & 2 deletions content/shared/influxdb3-cli/create/distinct_cache.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

The `influxdb3 create distinct_cache` command creates a new distinct value cache.

## Usage
Expand Down Expand Up @@ -52,4 +51,79 @@ 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, you must:

1. Create a [database](/influxdb3/version/reference/cli/influxdb3/create/database/).

2. Create a [table](/influxdb3/version/reference/cli/influxdb3/create/table/) with the columns you want to cache.

3. Have a valid authentication token.

## Examples

{{% code-placeholders "(DATABASE|TABLE|COLUMN|CACHE)_NAME" %}}

### Generix syntax

Use this as a template to adapt the command to your environment.

<!--pytest.mark.skip-->

```bash
influxdb3 create distinct_cache \
--database DATABASE_NAME \
--table TABLE_NAME \
--column COLUMN_NAME \
CACHE_NAME
```

In the example above, replace the following:

- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}:
Database name
- {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}}:
Table name
- {{% code-placeholder-key %}}`CACHE_NAME`{{% /code-placeholder-key %}}:
Name of the distinct value cache to create
- {{% code-placeholder-key %}}`COLUMN_NAME`{{% /code-placeholder-key %}}: Column to cache distinct values from

### Create a distinct value cache for one column

Use this simple setup to test the cache functionality for a single tag column. It’s helpful when validating basic behavior or building up incrementally.

<!--pytest.mark.skip-->

```bash
influxdb3 create distinct_cache \
--database my_test_db \
--table my_sensor_table \
--columns room \
my_room_cache
```

### Create a hierarchical cache with constraints

Use this pattern when you need more control over cache structure and retention. It creates a multilevel cache with resource limits.

<!--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 pitfals

- `--column` is not valid—must 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

82 changes: 80 additions & 2 deletions content/shared/influxdb3-cli/create/last_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ The `influxdb3 create last_cache` command creates a new last value cache.
<!--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> \
[CACHE_NAME]
```

## Arguments
Expand Down Expand Up @@ -40,4 +43,79 @@ 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, you must:

Before creating a distinct value cache, you must:

1. Create a [database](/influxdb3/version/reference/cli/influxdb3/create/database/).

2. Create a [table](/influxdb3/version/reference/cli/influxdb3/create/table/) with the columns you want to cache.

3. Have a valid authentication token.

## Examples

### Generic syntax

{{% code-placeholders "(DATABASE|TABLE|CACHE)_NAME (TAG_COLUMN|FIELD_COLUMN)" %}}

<!--pytest.mark.skip-->

```bash
influxdb3 create last_cache \
--database DATABASE_NAME \
--table TABLE_NAME \
--key-columns TAG_COLUMN \
--value-columns FIELD_COLUMN \
CACHE_NAME
```

In the example above, replace the following:

- {{% code-placeholder-key %}}`DATABASE_NAME`{{% /code-placeholder-key %}}: Database name
- {{% code-placeholder-key %}}`TABLE_NAME`{{% /code-placeholder-key %}}: Table name
- {{% code-placeholder-key %}}`TAG_COLUMN`{{% /code-placeholder-key %}}: Column to use as the key in the cache
- {{% code-placeholder-key %}}`FIELD_COLUMN`{{% /code-placeholder-key %}}: Column to store as the value in the cache
- {{% code-placeholder-key %}}`CACHE_NAME`{{% /code-placeholder-key %}}: Optional name for the last value cache

## Create a basic last value cache for one column

Use this example to create a simple cache for a single key and value column:

<!--pytest.mark.skip-->

```bash
influxdb3 create last_cache \
--database DATABASE_NAME \
--table my_sensor_table \
--key-columns room \
--value-columns temp \
my_temp_cache
```

## Create a last value cache with multiple keys and values

This example shows how to configure a more complex cache:

<!--pytest.mark.skip-->

```bash
influxdb3 create last_cache \
--database DATABASE_NAME \
--table my_sensor_table \
--key-columns room,sensor_id \
--value-columns temp,hum \
--count 10 \
--ttl 1h \
my_sensor_cache
```

{{% /code-placeholders %}}

## Common pitfalls

- All specified key and value columns must exist in the table schema.
- Tokens must be passed with `--token` unless set via environment variable.
- If not specified, default values are used for `--count` and `--ttl`.
Comment on lines +101 to +103
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer active voice.

45 changes: 0 additions & 45 deletions content/shared/influxdb3-cli/create/plugin.md

This file was deleted.

40 changes: 40 additions & 0 deletions content/shared/influxdb3-cli/create/table.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,44 @@ influxdb3 create table \
TABLE_NAME
```

### Verification

Use the following command to confirm that your table was created:

<!--pytest.mark.skip-->

```bash
influxdb3 query \
--database DATABASE_NAME \
--token AUTH_TOKEN \
"SHOW TABLES"
```

If successful, you’ll see a list of tables in the specified database, including the new one. The expected output should look similar to:

<!--pytest.mark.skip-->

```bash
+---------------+--------------------+----------------------------+------------+
| 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 |
| public | system | processing_engine_logs | BASE TABLE |
| public | system | processing_engine_triggers | BASE TABLE |
| public | system | queries | BASE TABLE |
| public | information_schema | tables | VIEW |
| public | information_schema | views | VIEW |
| public | information_schema | columns | VIEW |
| public | information_schema | df_settings | VIEW |
| public | information_schema | schemata | VIEW |
+---------------+--------------------+----------------------------+------------+
```

>[!Note]
> The `SHOW TABLES SQL` query must be run using the influxdb3 query CLI.
> HTTP requests to /api/v3/query are not supported in local or OSS builds of {{< product-name >}}.

{{% /code-placeholders %}}
34 changes: 27 additions & 7 deletions content/shared/influxdb3-cli/create/token.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

The `influxdb3 create token` command creates a new authentication token.

## Usage

<!--pytest.mark.skip-->

```bash
influxdb3 create token <COMMAND> [OPTIONS]
influxdb3 create token <SUBCOMMAND>
```

## Commands
Expand All @@ -18,15 +17,36 @@ 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
```
```

This returns a token string. You can use it to authenticate future requests by setting it with `--token` or the `INFLUXDB3_AUTH_TOKEN` environment variable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This returns a token string. You can use it to authenticate future requests by setting it with `--token` or the `INFLUXDB3_AUTH_TOKEN` environment variable.
The output is the raw token string you can use it 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.

Also, include the note from /admin/tokens (this is the only time you can access the token string, securely store your token string)


### Use the token to create a database

<!--pytest.mark.skip-->

```bash
influxdb3 create database \
--token YOUR_ADMIN_TOKEN \
my_new_database
```

> [!Tip]
> Set the token as an environment variable to simplify repeated commands:
> ```bash
> export INFLUXDB3_AUTH_TOKEN=YOUR_ADMIN_TOKEN
> ```
Loading