influxdb-rust icon indicating copy to clipboard operation
influxdb-rust copied to clipboard

Influxdb v2

Open qm3ster opened this issue 4 years ago • 21 comments

Is it within the scope of this project to support InfluxDB v2.0.0?

qm3ster avatar Mar 15 '20 22:03 qm3ster

Definetly! We'd have to think how supporting both versions could look and how features need to be adapted.

Empty2k12 avatar Mar 15 '20 22:03 Empty2k12

Hi guys I am working for v2 https://github.com/xoac/influxdb2

xoac avatar Mar 16 '20 11:03 xoac

I started working on a v2 branch as well and will start pushing once I have something to show 👍

Empty2k12 avatar Mar 16 '20 12:03 Empty2k12

@Empty2k12 Could you say how long you will be doing this? I don't wanna double work I would prefer just create PR.

xoac avatar Mar 16 '20 15:03 xoac

@xoac Feel free to open a PR for v2 if you have something fully working already. I had just started didn't have a chance to work on it any further due to Corona.

Empty2k12 avatar Apr 06 '20 00:04 Empty2k12

I think I would like to attempt this (within this project). I know the line protocol is identical, and this library did not use UDP, do you have some notes on what actually needs changing? I imagine authentication, since tokens are now used instead of username+password?

I also see the new Serde feature, not sure if the return format of queries is compatible. The query format itself definitely isn't, InfluxQL was deprecated, queries are in Flux language now.

So, any notes? &@xoac

qm3ster avatar Jun 01 '20 21:06 qm3ster

I have defined influx-db line protocol as separate crate: https://github.com/xoac/influxdb-line-protocol and used it with https://github.com/xoac/influxdb2 that at this moment support only writes.

In my opinion if someone is using influxdb v2 shouldn't be forced to go through documentation that are about v1 version and vice-versa. Separate line protocol is natural consequence of above. Rust has awesome dependencies support and splinting things is so easy.

If you want to look how I use inlfuxdb2 with rust I wrote some examples: https://github.com/xoac/influxdb2/tree/master/examples

What I have created incorrectly was PointBuilder this should be definitely refactored

xoac avatar Jun 01 '20 22:06 xoac

@xoac thank you.

  1. At the moment I only need writes. However, what I expect a library to be able to do is batch data points while:
    1. sorting by timestamp
    2. sorting tags by key as per performance tips
    3. set per-client (or per-batch) timestamp precision, which should affect:
      1. query string precision=[ns,u,ms,s,m,h]
      2. locally sampled time (probably handled by storing Instant, see below)
      3. serialization precision of std::time::Instant and types from chrono crate
  2. I am not sure what you meant by "separate line protocol": https://docs.influxdata.com/influxdb/v1.8/write_protocols/line_protocol_reference and https://v2.docs.influxdata.com/v2.0/reference/syntax/line-protocol/ seem identical?

qm3ster avatar Jun 02 '20 14:06 qm3ster

I mean that I needed to create separate crate because influxdb (this project) define line protocol internally and in my opinion it should be separte crate (used by influxdb and influxdb v2 clients). In my opinion ideal scenario would be cargo workspace to have code in one repo but creating holding more crates

xoac avatar Jun 02 '20 16:06 xoac

Actually v2 has a set of APIs that compatible with v1 (/query and /write), with authorization required. It could be possible to slightly change current client API to make it work with this.

sunng87 avatar Mar 10 '21 07:03 sunng87

@sunng87 That sounds wonderful. I think it's important to keep compatibility with v1.

Empty2k12 avatar Mar 10 '21 14:03 Empty2k12

I'm definitely interested in just being able to serialize/deserialize v2 requests/responses. Might be worth detaching the client part of the codebase from the raw line protocol one. But I understand that is a very low priority thing. Should we be able to deserialize v2 responses using the logic from this crate?

doivosevic avatar Jun 15 '21 11:06 doivosevic

I have added initial write support here. Meaning it works for me for sending values in a simple scenario. There might be some hidden issues. The branch is based on #92.

Differences I encountered so far are:

  • db query parameter is replaced by org and bucket.
  • token parameter seems to be mandatory (not sure here).
  • minute and hour timestamp precision are no longer supported
  • microseconds precision is now us instead of u

I have added a v2 feature and made it the default. Write query looks like this now:

let _client = Client::new("http://localhost:8086", "ORG", "YOUR_BUCKET", "YOUR API TOKEN");
let write_query = Timestamp::Milliseconds(1629703212874)
        .into_query("tst")
        .add_field("foo", "bar");
client.query(&write_query).await?;

Given that it's based on #92 I will wait until this is merged before creating a PR.

marcelbuesing avatar Aug 23 '21 07:08 marcelbuesing

Looks like #92 has been merged.

iicurtis avatar Oct 16 '21 18:10 iicurtis

@marcelbuesing how far are you on the changes?

Or is there a way to use the library using the v1 api?

johansmitsnl avatar Dec 05 '21 10:12 johansmitsnl

Perhaps a dead thread, but wondering if v2 support is on its way or shelved indefinitely.

reeslabree avatar Sep 12 '22 19:09 reeslabree

@reeslabree Afaik there's nobody actively working on this project right now, but I'll be happy to merge a PR if you want to implement this.

msrd0 avatar Sep 14 '22 16:09 msrd0

@msrd0 All good, it looks like theres an influxdb2 crate out that accomplishes v2 support.

reeslabree avatar Sep 14 '22 16:09 reeslabree

Hi! Any news on support for v2 in this crate?

EstebanBorai avatar Oct 15 '23 21:10 EstebanBorai

The compatibility mode of InfluxDB 2.0 is supported since version 0.6 of this crate (I recommend using the latest available version).

msrd0 avatar Oct 16 '23 12:10 msrd0

The compatibility mode of InfluxDB 2.0 is supported since version 0.6 of this crate (I recommend using the latest available version).

If that is the case, can we close this issue ?

patrickelectric avatar Nov 15 '23 19:11 patrickelectric