brontide / aioedgeos

Async version of code to interact with EdgeOS API and streaming statistics daemon.
37 stars 8 forks source link

influxDB version required? #16

Open xanderphillips opened 1 year ago

xanderphillips commented 1 year ago

I'm trying to get this to work with influxDB2 and am having difficulty getting the docker image to have permission to write to the influxDB2 database.

Getting error: aioinflux.client.InfluxDBWriteError: Error writing data (401 - Unauthorized):

This is likely due to my own ignorance in granting permission on an influxDB2 database and not due to the code. I have data being published form other sources, but they understand using API token instead of username/password.

Any assistance greatly appreciated.

brontide commented 1 year ago

I never looked at token auth since I never set that up on influx. I've created a branch with a possible solution given the fact that logging into influx looks like you just add token=TOKEN rather than username=USERNAME, password=PASSWORD. This is just a matter of adjusting the influx_auth dict near the beginning since that is injected into the client setup **influx_auth.

I have done zero testing but this branch should allow the use of the environment variable INFLUX_TOKEN to authenticate.

xanderphillips commented 1 year ago

Thank you! Now I just need to figure out how to build a new docker image from a github branch. (New to all of this).

xanderphillips commented 1 year ago

Replaced the influx.py in my existing container as I saw that was the only file you modified. Docker container failed to start, and found this in the docker log:

File "/app/influx.py", line 75 'token': INFLUX_TOKEN  ^ SyntaxError: invalid syntax

I will try to find out what the expected argument name is for a python influxdb2 token and report back.

brontide commented 1 year ago

That sounds correct, I was copying from the other block and mistook the ({}) for (())

lonestaritaly commented 1 year ago

Btw it doesn't work in any case. Python module aioinflux doesn't support InfluxDB 2.0. I understand It would be needed to switch to module aioinfluxdb.