Skip to content
@jennifer/influxdb

influxdb cheatsheet

Every export of @jennifer/influxdb. The guide is the introduction.

jennifer
import "@jennifer/influxdb/" as influxdb;

Functions

FunctionReturnsDoes
influxdb.client(url as string, db as string)ClientOpen a client to a database with no authentication
influxdb.clientWith(url as string, db as string, user as string, password as string)ClientOpen a 1.x client with HTTP Basic-auth credentials
influxdb.client2(url as string, org as string, bucket as string, token as string)ClientOpen an InfluxDB 2.x client
influxdb.point(measurement as string)PointStart a point for a measurement (no tags or fields yet)
influxdb.tag(p as Point, key as string, value as string)PointAdd a tag (indexed string metadata)
influxdb.field(p as Point, key as string, value as float)PointAdd a float field
influxdb.intField(p as Point, key as string, value as int)PointAdd an integer field (rendered with the line-protocol i suffix)
influxdb.stringField(p as Point, key as string, value as string)PointAdd a string field (double-quoted, escaped)
influxdb.boolField(p as Point, key as string, value as bool)PointAdd a boolean field
influxdb.at(p as Point, unixNanos as int)PointSet an explicit timestamp in nanoseconds since the Unix epoch
influxdb.atTime(p as Point, t as time.Time)PointSet the timestamp from a time.Time
influxdb.line(p as Point)stringRender a point to one line-protocol line
influxdb.write(c as Client, points as list of Point)Write points to the client's target (line protocol, nanosecond precision)
influxdb.query(c as Client, influxql as string)ResultRun an InfluxQL statement against a 1.x client's database and parse the result
influxdb.queryFlux(c as Client, flux as string)stringRun a Flux query against a 2.x client's organization and return the raw response body

Types

Client

A client for either API generation.

FieldMeaning
url as stringthe base URL (e.g. "http://localhost:8086")
version as Versionthe API generation (V1 or V2)
db as stringthe 1.x database name ("" for a 2.x client)
user as stringthe 1.x Basic-auth username ("" for no auth)
password as stringthe 1.x Basic-auth password
org as stringthe 2.x organization ("" for a 1.x client)
bucket as stringthe 2.x bucket ("" for a 1.x client)
token as stringthe 2.x API token ("" for a 1.x client)

Point

A line-protocol point under construction.

FieldMeaning
measurement as stringthe measurement name
tags as list of stringescaped key=value tag fragments
fields as list of stringrendered key=value field fragments
timestamp as intthe timestamp in nanoseconds (when timed)
timed as boolwhether an explicit timestamp is set

Series

One result series.

FieldMeaning
name as stringthe measurement name
tags as map of string to stringthe series tag set ({} if none)
columns as list of stringthe column names (e.g. ["time", "value"])
values as list of list of stringthe rows, one stringified cell per column

Result

A parsed query result.

FieldMeaning
series as list of Seriesthe result series

Version

The API generation a Client targets.

VariantMeaning
V1InfluxDB 1.x: /write?db=..., InfluxQL, optional Basic auth
V2InfluxDB 2.x: /api/v2/write?org=...&bucket=..., Flux, token auth (3.x takes the writes)