Skip to content

Commit d1e44a4

Browse files
update: fix some wording and hierarchy
1 parent 7671805 commit d1e44a4

File tree

1 file changed

+40
-33
lines changed

1 file changed

+40
-33
lines changed

content/shared/v3-core-plugins/_index.md

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11

2-
Use the {{% product-name %}} Processing engine to run code and perform tasks
2+
Use the {{% product-name %}} ProcessingEngine to run code and perform tasks
33
for different database events.
44

5-
{{% product-name %}} provides the InfluxDB 3 Processing engine, an embedded Python VM that can dynamically load and trigger Python plugins
5+
{{% product-name %}} provides the InfluxDB 3 Processing Engine, an embedded Python VM that can dynamically load and trigger Python plugins
66
in response to events in your database.
77

8-
## Plugins
8+
## Key Concepts
9+
10+
### Plugins
11+
12+
A Processing Engine _plugin_ is Python code you provide to run tasks, such as
13+
downsampling data, monitoring, creating alerts, or calling external services.
914

1015
> [!Note]
1116
> #### Contribute and use community plugins
@@ -14,31 +19,30 @@ in response to events in your database.
1419
> and contribute example plugins.
1520
> You can reference plugins from the repository directly within a trigger configuration.
1621
17-
A Processing engine _plugin_ is Python code you provide to run tasks, such as
18-
downsampling data, monitoring, creating alerts, or calling external services.
19-
20-
## Triggers
22+
### Triggers
2123

2224
A _trigger_ is an InfluxDB 3 resource you create to associate a database
2325
event (for example, a WAL flush) with the plugin that should run.
24-
When an event occurs, the trigger passes configuration, optional arguments, and event data to the plugin.
26+
When an event occurs, the trigger passes configuration details, optional arguments, and event data to the plugin.
2527

26-
The Processing engine provides four types of plugins and triggers--each type corresponds to an event type with event-specific configuration to let you handle events with targeted logic.
28+
The Processing Engine provides four types of triggerseach type corresponds to an event type with event-specific configuration to let you handle events with targeted logic.
2729

28-
- **WAL flush**: Triggered when the write-ahead log (WAL) is flushed to the object store (default is every second)
29-
- **Parquet persistence (coming soon)**: Triggered when InfluxDB 3 persists data to object store Parquet files
30-
- **Scheduled tasks**: Triggered on a schedule you specify using cron syntax
31-
- **On Request**: Bound to the HTTP API `/api/v3/engine/<CUSTOM_PATH>` endpoint and triggered by a GET or POST request to the endpoint.
30+
- **WAL Flush**: Triggered when the write-ahead log (WAL) is flushed to the object store (default is every second).
31+
- **Scheduled Tasks**: Triggered on a schedule you specify using cron syntax.
32+
- **On Request**: Triggered on a GET or POST request to the bound HTTP API endpoint at `/api/v3/engine/<CUSTOM_PATH>`.
33+
- **Parquet Persistence (coming soon)**: Triggered when InfluxDB 3 persists data to object storage Parquet files.
3234

33-
## Activate the Processing engine
35+
### Activate the Processing Engine
3436

35-
To enable the Processing engine, start the {{% product-name %}} server with the `--plugin-dir` option and a path to your plugins directory (it doesn't need to exist yet)--for example:
37+
To enable the Processing Engine, start the {{% product-name %}} server with the `--plugin-dir` option and a path to your plugins directory. If the directory doesn’t exist, the server creates it.
3638

3739
```bash
38-
influxdb3 serve --node-id node0 --plugin-dir /path/to/plugins
40+
influxdb3 serve --node-id node0 --object-store [OBJECT STORE TYPE] --plugin-dir /path/to/plugins
3941
```
4042

41-
## Shared API
43+
44+
45+
## The Shared API
4246

4347
All plugin types provide the InfluxDB 3 _shared API_ for interacting with the database.
4448
The shared API provides access to the following:
@@ -47,7 +51,7 @@ The shared API provides access to the following:
4751
- `query` to query data from any database
4852
- `info`, `warn`, and `error` to log messages to the database log, which is output in the server logs and captured in system tables queryable by SQL
4953

50-
### Line builder
54+
### LineBuilder
5155

5256
The `LineBuilder` is a simple API for building lines of Line Protocol to write into the database. Writes are buffered while the plugin runs and are flushed when the plugin completes. The `LineBuilder` API is available in all plugin types.
5357

@@ -198,12 +202,12 @@ influxdb3_local.query("SELECT * from foo where bar = $bar and time > now() - 'in
198202
### Logging
199203

200204
The shared API `info`, `warn`, and `error` functions log messages to the database log, which is output in the server logs and captured in system tables queryable by SQL.
201-
The `info`, `warn`, and `error` functions are available in all plugin types. The functions take an arbitrary number of arguments, convert them to strings, and then join them into a single message separated by a space.
205+
The `info`, `warn`, and `error` functions are available in all plugin types. Each function accepts multiple arguments, converts them to strings, and logs them as a single, space-separated message.
202206

203-
The following examples show to use the `info`, `warn`, and `error` logging functions:
207+
The following examples show how to use the `info`, `warn`, and `error` logging functions:
204208

205209
```python
206-
ifluxdb3_local.info("This is an info message")
210+
influxdb3_local.info("This is an info message")
207211
influxdb3_local.warn("This is a warning message")
208212
influxdb3_local.error("This is an error message")
209213

@@ -212,10 +216,10 @@ obj_to_log = {"hello": "world"}
212216
influxdb3_local.info("This is an info message with an object", obj_to_log)
213217
```
214218

215-
### Trigger arguments
219+
### Trigger Arguments
216220

217221
Every plugin type can receive arguments from the configuration of the trigger that runs it.
218-
You can use this to provide runtime configuration and drive behavior of a plugin--for example:
222+
You can use this to provide runtime configuration and drive behavior of a pluginfor example:
219223

220224
- threshold values for monitoring
221225
- connection properties for connecting to third-party services
@@ -233,9 +237,9 @@ def process_writes(influxdb3_local, table_batches, args=None):
233237
influxdb3_local.warn("No threshold provided")
234238
```
235239

236-
The `args` parameter is optional and can be omitted from the trigger definition if the plugin doesn't need to use arguments.
240+
The `args` parameter is optional. If a plugin doesn’t require arguments, you can omit it from the trigger definition.
237241

238-
## Import plugin dependencies
242+
## Import Plugin Dependencies
239243

240244
Use the `influxdb3 install` command to download and install Python packages that your plugin depends on.
241245

@@ -267,14 +271,17 @@ influxdb3 install package <PACKAGE_NAME>
267271
```
268272

269273
The result is an active Python virtual environment with the package installed in `<PLUGINS_DIR>/.venv`.
270-
You can pass additional options to use a `requirements.txt` file or a custom virtual environment path.
274+
You can specify additional options to install dependencies from a `requirements.txt` file or a custom virtual environment path.
271275
For more information, see the `influxdb3` CLI help:
272276

273277
```bash
274278
influxdb3 install package --help
275279
```
276280

277-
## WAL flush plugin
281+
## Trigger Types and How They Work
282+
Triggers define when and how plugins execute in response to database events. Each trigger type corresponds to a specific event, allowing precise control over automation within {{% product-name %}}.
283+
284+
### WAL Flush Trigger
278285

279286
When a WAL flush plugin is triggered, the plugin receives a list of `table_batches` filtered by the trigger configuration (either _all tables_ in the database or a specific table).
280287

@@ -302,7 +309,7 @@ def process_writes(influxdb3_local, table_batches, args=None):
302309
influxdb3_local.info("wal_plugin.py done")
303310
```
304311

305-
### WAL flush trigger Configuration
312+
#### WAL flush trigger configuration
306313

307314
When you create a trigger, you associate it with a database and provide configuration specific to the trigger type.
308315

@@ -330,7 +337,7 @@ For more information about trigger arguments, see the CLI help:
330337
influxdb3 create trigger help
331338
```
332339

333-
## Schedule Plugin
340+
### Schedule Trigger
334341

335342
Schedule plugins run on a schedule specified in cron syntax. The plugin will receive the local API, the time of the trigger, and any arguments passed in the trigger definition. Here's an example of a simple schedule plugin:
336343

@@ -347,7 +354,7 @@ def process_scheduled_call(influxdb3_local, time, args=None):
347354
influxdb3_local.error("No table_name provided for schedule plugin")
348355
```
349356

350-
### Schedule Trigger Configuration
357+
#### Schedule trigger configuration
351358

352359
Schedule plugins are set with a `trigger-spec` of `schedule:<cron_expression>` or `every:<duration>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted to use the system-metrics example from the Github repo and have it collect every 10 seconds we could use the following trigger definition:
353360

@@ -358,7 +365,7 @@ influxdb3 create trigger \
358365
--database mydb system-metrics
359366
```
360367

361-
## On Request Plugin
368+
### On Request Trigger
362369

363370
On Request plugins are triggered by a request to a specific endpoint under `/api/v3/engine`. The plugin will receive the local API, query parameters `Dict[str, str]`, request headers `Dict[str, str]`, request body (as bytes), and any arguments passed in the trigger definition. Here's an example of a simple On Request plugin:
364371

@@ -385,7 +392,7 @@ def process_request(influxdb3_local, query_parameters, request_headers, request_
385392
return 200, {"Content-Type": "application/json"}, json.dumps({"status": "ok", "line": line_str})
386393
```
387394

388-
### On Request Trigger Configuration
395+
#### On request trigger configuration
389396

390397
On Request plugins are set with a `trigger-spec` of `request:<endpoint>`. The `args` parameter can be used to pass configuration to the plugin. For example, if we wanted the above plugin to run on the endpoint `/api/v3/engine/my_plugin`, we would use `request:my_plugin` as the `trigger-spec`.
391398

@@ -394,6 +401,6 @@ Trigger specs must be unique across all configured plugins, regardless of which
394401
```shell
395402
influxdb3 create trigger \
396403
--trigger-spec "request:hello-world" \
397-
--plugin-filename "hellp/hello_world.py" \
404+
--plugin-filename "hello/hello_world.py" \
398405
--database mydb hello-world
399406
```

0 commit comments

Comments
 (0)