InfluxElixir.Client.Local.LineProtocolParser (InfluxElixir v0.1.24)

Copy Markdown View Source

Line protocol parser for InfluxElixir.Client.Local.

Turns a line-protocol payload into point maps, honouring the escaping rules of the format (escaped spaces, commas, equals signs, backslashes and quotes) and the write precision. Errors have the same %{status: 400, body: ...} shape a real InfluxDB write endpoint returns.

Summary

Types

A parsed point: fields and tags as string-keyed maps, timestamp in ns.

Functions

Parses a line-protocol payload into points.

Undoes line-protocol escaping in a measurement name (\, \,, \\).

Types

point()

@type point() :: %{
  measurement: binary(),
  tags: %{required(binary()) => binary()},
  fields: %{required(binary()) => term()},
  timestamp: integer() | nil
}

A parsed point: fields and tags as string-keyed maps, timestamp in ns.

Functions

parse(text, precision)

@spec parse(binary(), atom()) :: {:ok, [point()]} | {:error, map()}

Parses a line-protocol payload into points.

Blank lines and # comments are skipped. precision is one of :nanosecond | :microsecond | :millisecond | :second and scales numeric timestamps to nanoseconds. A point without a timestamp keeps nil; the caller assigns the server time.

unescape_measurement(str)

@spec unescape_measurement(binary()) :: binary()

Undoes line-protocol escaping in a measurement name (\, \,, \\).