influxdblineprotocol

This crate contains pure Rust implementations of

  1. A parser for [InfluxDB Line Protocol] developed as part of the [InfluxDB IOx] project. This implementation is intended to be compatible with the [Go implementation], however, this implementation uses a [nom] combinator-based parser rather than attempting to port the imperative Go logic so there are likely some small diferences.

  2. A builder to contruct valid [InfluxDB Line Protocol]

Example

Here is an example of how to parse the following line protocol data into a ParsedLine:

text cpu,host=A,region=west usage_system=64.2 1590488773254420000

```rust use influxdblineprotocol::{ParsedLine, FieldValue};

let mut parsedlines = influxdblineprotocol::parselines( "cpu,host=A,region=west usagesystem=64i 1590488773254420000" ); let parsedline = parsed_lines .next() .expect("Should have at least one line") .expect("Should parse successfully");

let ParsedLine { series, fieldset, timestamp, } = parsedline;

assert_eq!(series.measurement, "cpu");

let tags = series.tagset.unwrap(); asserteq!(tags[0].0, "host"); asserteq!(tags[0].1, "A"); asserteq!(tags[1].0, "region"); assert_eq!(tags[1].1, "west");

let field = &fieldset[0]; asserteq!(field.0, "usagesystem"); asserteq!(field.1, FieldValue::I64(64));

assert_eq!(timestamp, Some(1590488773254420000)); ```