Packages
influx_elixir
0.1.44
0.1.46
0.1.45
0.1.44
0.1.43
0.1.42
0.1.41
0.1.40
0.1.39
0.1.38
0.1.37
0.1.36
0.1.35
0.1.34
0.1.33
0.1.32
0.1.31
0.1.30
0.1.29
0.1.28
0.1.27
0.1.26
0.1.25
0.1.24
0.1.23
0.1.22
0.1.21
0.1.20
0.1.19
0.1.18
0.1.17
0.1.16
0.1.15
0.1.14
0.1.13
0.1.12
0.1.11
0.1.10
0.1.9
0.1.8
0.1.7
0.1.6
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
Elixir client library for InfluxDB v3 with v2 compatibility
Current section
Files
Jump to
Current section
Files
influx_elixir
usage-rules.md
usage-rules.md
# InfluxElixir Usage Rules
## Connection Setup
- Configure connections under `config :influx_elixir, :connections`; the library is an OTP application and starts a supervisor with a Finch pool per connection — do not start Finch yourself
- `host:` is a bare hostname; `scheme:` and `port:` are separate options
- Configure `api_version: :v3` (default) or `:v2` for InfluxDB 2.x — a v2 server accepts the v3 write path with `200` but stores nothing
- HTTP connection configs are validated at startup; unknown keys (e.g. `default_database:`) are errors — the key is `database:`
- Use named connections for multi-instance support; add or remove them at runtime with `InfluxElixir.add_connection/2` and `remove_connection/1`
## Writing Data
- All write operations go through the `InfluxElixir` facade module
- Use `InfluxElixir.point/3` to construct points (measurement, tags, fields)
- Use `InfluxElixir.write/2,3` for direct writes; the first argument is a connection name or connection term
- Batch writers are managed internally by the supervision tree — configure via `batch_writer:` in the connection config, not direct GenServer interaction
- Integer fields are suffixed with `i` in line protocol — the library handles this
## Querying Data
- All query operations go through the `InfluxElixir` facade module
- Always use parameterized queries with `$param` placeholders (a map) — never interpolate
- Use `InfluxElixir.query_sql_stream/3` for large result sets (returns lazy Stream)
- Use `InfluxElixir.query_sql/3` for bounded result sets
- `time` values are `DateTime` with microsecond precision
## Testing
- Configure `:influx_elixir, :client` to use the LocalClient in `config/test.exs` — no real InfluxDB needed
- Use `InfluxElixir.TestHelper.setup_influx/1` in test setup for isolated per-test state
- LocalClient stores data in ETS and responds like a real InfluxDB server; concurrent writers are safe
- Run integration tests against real InfluxDB with `--include integration` tag
## Error Handling
- All operations return `{:ok, result}` or `{:error, reason}` tuples
- HTTP failures are `{:error, %{status: integer, body: binary}}`; transport failures are `{:error, {:connection_error, reason}}` with `:pool_timeout` when no connection could be checked out in time
- Streaming queries raise `InfluxElixir.StreamError` (with a `:kind`) when enumerated