Skip to main content

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()
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

License

Licensed under either of Apache License 2.0 or MIT license at your option.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

influxdata_plugin_utils-0.1.0.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

influxdata_plugin_utils-0.1.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file influxdata_plugin_utils-0.1.0.tar.gz.

File metadata

  • Download URL: influxdata_plugin_utils-0.1.0.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for influxdata_plugin_utils-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f23a8a075228cf7f313359919e5ff91bbdbe80a117ba9464e9ca73263362f656
MD5 2aea9665e891c94e023ab8e9fa8db205
BLAKE2b-256 c0cfdc646c71a17eec1c2f8454754257e34ec2d017eceefd18a1adcdcd8a13c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for influxdata_plugin_utils-0.1.0.tar.gz:

Publisher: publish-influxdata-plugin-utils.yml on influxdata/influxdb3_plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file influxdata_plugin_utils-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for influxdata_plugin_utils-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 427b3654718d40bdcc3c10b98e9fb861083872ecefcb4544aae9f91d3f41fd88
MD5 03764d173155cedbe8228444f5574f8f
BLAKE2b-256 e7308a5fc0cb441c6248e416464020ea1a3d05ea8154c9092230177d5690f5cb

See more details on using hashes here.

Provenance

The following attestation bundles were made for influxdata_plugin_utils-0.1.0-py3-none-any.whl:

Publisher: publish-influxdata-plugin-utils.yml on influxdata/influxdb3_plugins

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page