sensors-software icon indicating copy to clipboard operation
sensors-software copied to clipboard

Support for Influx2

Open 9lstr opened this issue 3 years ago • 8 comments

Is there a way to send data to an Influx 2.0 database? There is a new auth process that uses a token instead of username and password. I have not found a solution in the current software for authorization with the Influx token.

9lstr avatar Jan 19 '21 12:01 9lstr

So basically InfluxDB2 has a 1.x compatibility mode, which suggests to use the username as username and the Token as Password: https://docs.influxdata.com/influxdb/v2.0/reference/api/influxdb-1x/#basic-authentication

Looking at the code, it seems that the maximum length a password can have is 64bytes: https://github.com/opendata-stuttgart/sensors-software/blob/b78aa0a059da6c867f5dc75f29dc86fa112808b9/airrohr-firmware/defines.h#L14

The catch is that the InfluxDB2 Tokens have 88bytes :slightly_frowning_face:

m-bucher avatar Feb 26 '21 21:02 m-bucher

Hello @9lstr , @m-bucher The new beta firmware should have a longer password field. So the compatibility mode should work now. Could you please test this?

ricki-z avatar Apr 01 '21 18:04 ricki-z

Hello @ricki-z, For me the mentioned documentation is not clear. So I tried several combinations of user and password and none of them worked. There is definitely one more change in the GUI necessary. The input field has a 'maxlength="64"' definition in the html. Can you change that? Afterwards I will test it again.

9lstr avatar Apr 06 '21 15:04 9lstr

The latest beta (published yesterday in the evening) should have a larger input field.

ricki-z avatar Apr 08 '21 23:04 ricki-z

If you want to use the V2 API you will need to send a "Authorization" header via Post and some other stuff. (Would be neat if the will work out of the box :D ) But you can still use the V1 authentifcation with Inlfux V2.

  • Create a bucket
  • Create an V1 user
  • Create a Retention Policy $ influx v1 auth create --username 'username' --write-bucket 'bucket-id' --password 'password' --org 'Org Name' $ influx v1 dbrp create --bucket-id (from above) --db feinstaub --org 'Org Name' --default --rp feinstaub

I'm not realy sure about the '--rp' flag if it's just a name or something else....

apuls avatar Jun 13 '21 13:06 apuls

If you want to use the V2 API you will need to send a "Authorization" header via Post and some other stuff. (Would be neat if the will work out of the box :D ) But you can still use the V1 authentifcation with Inlfux V2.

  • Create a bucket
  • Create an V1 user
  • Create a Retention Policy $ influx v1 auth create --username 'username' --write-bucket 'bucket-id' --password 'password' --org 'Org Name' $ influx v1 dbrp create --bucket-id (from above) --db feinstaub --org 'Org Name' --default --rp feinstaub

I'm not realy sure about the '--rp' flag if it's just a name or something else....

I've tried to follow these steps but it doesn't really work for me. Since there is no real debug log on AirRohr's side, I am also not able to find the reason for why there is no data written to my influx2 instance. How did you set up your configuration on AirRohr's side? Can you post a screenshot of your settings?

ituri avatar Mar 15 '22 16:03 ituri

I finally figured it out. The steps that @apuls mentioned are correct, however I was lacking the correct path. In my (default?) configuration it said /query?db=iot, which doesn't work. The path has to be /write?db=iot instead. Screenshot 2022-04-23 at 08 53 52

However, I still think that Influx2 support would be a good thing since I don't think that Influx 2.x will have backwards compatibility to 1.x for forever.

ituri avatar Apr 23 '22 06:04 ituri

Native Influx v2 would be nice indeed.

chevdor avatar Mar 26 '24 16:03 chevdor