Influxdb error 401 connecting to influx on unraid docker

I’m new to influx and I set up the app on hubitat and setup an influx server on unraid docker and setup a bucket named hubitat but the log on hubitat sends back error 401. I’m thinking I have not set something up right on the influx server but I have the right username and password. Thanks

after doing some digging it seems the authentication header in hubitat is not correct but i cant seem to find how to change that. it seems that influx wants me to put the api token in the header but hubitat is not including this.

this is the header hubitat is trying to use :postToInfluxDB(): Posting data to InfluxDB: Host: 192.168.1.74, Port: 8086, Database: Hubitat

exact error: errorpostToInfluxDB(): Something went wrong! Response from InfluxDB: Status: 401, Headers: [X-Influxdb-Build:OSS, X-Platform-Error-Code:unauthorized, X-Influxdb-Version:2.1.0

From the error message it looks like it may be a user permission issue. Did you change the user permissions in Influx?

Screen Shot 2021-11-07 at 7.10.19 PM

Which app are you using within Hubitat to populate the database?

im using the influx db app from github i found onlinedownloaded the code and added as app. my docler app looks diiferent from yours since im running it from unraid docker so i dont see the permissions tab



See if this helps...

https://docs.influxdata.com/influxdb/v1.8/administration/authentication_and_authorization/#user-types-and-privileges

my issue is that with the influxdb logger i have in hubitat i dont see any place to input the API token which influx needs to allow access. im not sure if just the username and password is enough to push data to influx. thanks

The Influxdb Logger app does not require Maker API so there is nowhere to add a token.

Assuming this is the app you are using:

https://raw.githubusercontent.com/HubitatCommunity/InfluxDB-Logger/master/influxdb-logger.groovy

yes thats the app im using but i think influxdb docker container is different than the one you are using. i think its version 2.0 and it wants the api token in the request . this is why i see on the logs saying that the request to send info is not authorized

I'm running everything through Home Assistant so it is different. However, before moving all my database stuff to HA I was using the logger app and it worked fine. If you go into your Hubitat logs do you see any errors related to the logger app?

Try using your docker user name and password.

Not sure if you got this working or not but I was able running into the same issue as you with the 401 error. Took me a bit to figure it out but finally got it working. I guess Influx 2.x changed the way authentication works. To get the App to work you need to map a v1 user and v1 database. But you can't to that until you update the config with the token. There is v1 info in the Influx Documentation.

  1. Update config for authorization with API Token.
  2. Create a v1 user, will automatically map to user token in config. (need bucket id)
  3. Create a v1 dbrp mapping for database to bucket.

Hope this helps you or anyone else that was struggling like I was to get Influx running.

1 Like

What is the repository setting for the docker in Unraid.

On the unraid server go to the docker and click on the Docker. Review what it says for the Repository

If it says influxdb:latest you are likely running a newer version of Influxdb and i don't know if all of this stuff is compatiable.

Change it to influxdb:1.8.4-alpine and then click on done at the bottom of the page. That will load it back to the previous version. Then make sure you setup the database correctly.

If you want to run the newer version of the database you may find you need to make allot of changes to some of the apps that load data into it.

I think this just helped me .... eventually. So glad I found it. No idea how you figured it !
OMG, how overly convoluted and non-intuitive this was to get working.
For me it was a Windows install but the issue is clearly the same.

I think this needs capturing on one of the main threads about Influxdb setup.

Issue 1: All commands in CLI were failing with "error 401"
I was using the token name on the command line since I had no idea of the token ID
Solution: Cloned the API token which gave me a new token and allowed me to see the ID string
Then use that token on all CLI commands
./influx auth list -t "<TOKEN_ID>"

issue 2: Need to create a v1 user and v1 database
./influx v1 auth create --org <ORG> --username <USER> --password <PASSWORD> --read-bucket <BUCKET_ID> --write-bucket <BUCKET_ID> -t "<TOKEN_ID>"
./influx v1 dbrp list --org <ORG> -t "<TOKEN_ID>"