Shared helpers for InfluxDB 3 plugins.
Project description
influxdata-plugin-utils
Shared helpers for InfluxDB 3 plugins.
Install
pip install influxdata-plugin-utils
Editable, for local development:
pip install -e influxdata-plugin-utils
Modules
| Module | What it provides |
|---|---|
config |
load_plugin_config(args, validators) (dynaconf-backed), resolve_plugin_dir(), resolve_path(), re-exported Validator |
introspection |
get_table_names(), get_tag_names(), get_field_names(), query_window() with optional database= |
parsing |
parse_timedelta(), parse_timestamp_ns(), parse_int(), parse_bool(), parse_delimited_list(), parse_key_value() |
cache |
cached(influxdb3_local, key, producer, ttl_seconds=3600) |
write |
build_line(), build_line_typed(), add_field_with_type(), write_data(), BatchLines |
Config: precedence
load_plugin_config merges sources low → high: env vars → engine args → TOML file. A provided TOML config file overrides everything. Environment variables are read only when their exact names are passed via env_keys=[...]; nothing is read from the environment by default.
from influxdata_plugin_utils.config import load_plugin_config, Validator
from influxdata_plugin_utils.parsing import parse_timedelta
def process_scheduled_call(influxdb3_local, call_time, args):
cfg = load_plugin_config(
args,
validators=[
Validator("source_table", must_exist=True),
Validator("batch_size", default=1000, gte=1, lte=10000, cast=int),
Validator("window", default="5min", cast=parse_timedelta),
],
)
influxdb3_local.info(f"{cfg.source_table} window={cfg.window}")
TOML becomes native — no manual string parsing:
source_table = "cpu"
batch_size = 2000
excluded_fields = ["usage_idle", "usage_guest"]
Write helpers
LineBuilder is a runtime global injected into the plugin, so builders take the
class as their first argument:
from influxdata_plugin_utils.write import build_line, write_data
lines = [
build_line(LineBuilder, "cpu", tags={"host": "a"}, fields={"usage": 12.5}, time_ns=ts)
]
write_data(influxdb3_local, lines) # batched + retried by default
# write_data(influxdb3_local, lines, batch=False, retries=0) # opt out
# write_data(influxdb3_local, lines, database="other_db") # another database
# write_data(influxdb3_local, lines, no_sync=True) # write_sync API (3.8+)
Cross-database queries
On InfluxDB versions that support processing-engine cross-database queries,
the introspection helpers accept database= and pass it through to
influxdb3_local.query.
Cached schema results are separated per database.
from influxdata_plugin_utils.introspection import get_field_names, query_window
fields = get_field_names(influxdb3_local, "cpu", database="source_db")
rows = query_window(
influxdb3_local,
"cpu",
start=start,
end=end,
columns=fields,
database="source_db",
)
License
Licensed under either of Apache License 2.0 or MIT license at your option.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file influxdata_plugin_utils-0.2.0.tar.gz.
File metadata
- Download URL: influxdata_plugin_utils-0.2.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce6bf9fb55ec493e16997713155957f22c4138c494991220e5892cf894b986db
|
|
| MD5 |
9d4bb22a32c883ff74babf82e1de2bc3
|
|
| BLAKE2b-256 |
0dd3001dfce3553ae488b7ccb9767151c899230c45ecc52ad5efcfe24173c3c5
|
Provenance
The following attestation bundles were made for influxdata_plugin_utils-0.2.0.tar.gz:
Publisher:
publish-influxdata-plugin-utils.yml on influxdata/influxdb3_plugins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
influxdata_plugin_utils-0.2.0.tar.gz -
Subject digest:
ce6bf9fb55ec493e16997713155957f22c4138c494991220e5892cf894b986db - Sigstore transparency entry: 2168708243
- Sigstore integration time:
-
Permalink:
influxdata/influxdb3_plugins@efac44602473b2f80d6c00266b16665cc3bc3369 -
Branch / Tag:
refs/tags/utils-v0.2.0 - Owner: https://github.com/influxdata
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-influxdata-plugin-utils.yml@efac44602473b2f80d6c00266b16665cc3bc3369 -
Trigger Event:
push
-
Statement type:
File details
Details for the file influxdata_plugin_utils-0.2.0-py3-none-any.whl.
File metadata
- Download URL: influxdata_plugin_utils-0.2.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3aa167dce1cc90cab79aa6217a3f9829c81ac31f21ec6aba322bf99893f51d4
|
|
| MD5 |
489ba7695bc13092584bc0b30631e523
|
|
| BLAKE2b-256 |
dcd2824b55b3c2152c707138497c426df391d926944bd6badfede7d184beef9c
|
Provenance
The following attestation bundles were made for influxdata_plugin_utils-0.2.0-py3-none-any.whl:
Publisher:
publish-influxdata-plugin-utils.yml on influxdata/influxdb3_plugins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
influxdata_plugin_utils-0.2.0-py3-none-any.whl -
Subject digest:
f3aa167dce1cc90cab79aa6217a3f9829c81ac31f21ec6aba322bf99893f51d4 - Sigstore transparency entry: 2168708341
- Sigstore integration time:
-
Permalink:
influxdata/influxdb3_plugins@efac44602473b2f80d6c00266b16665cc3bc3369 -
Branch / Tag:
refs/tags/utils-v0.2.0 - Owner: https://github.com/influxdata
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-influxdata-plugin-utils.yml@efac44602473b2f80d6c00266b16665cc3bc3369 -
Trigger Event:
push
-
Statement type: