Getting started with InfluxDB / Docker - 401 (Unauthorized)

I’m more of an application developer than a docker / InfluxDB person.
I wish to explore using InluxDB to collect application telemetry - however, my first attempt has left me feeling like a worthless idiot!
It all looked so polished, clean and easy to use…

To get running :
C:\Users\jnewcomb>docker pull
v2.0.2: Pulling from influxdb/influxdb
6e640006d1cd: Pull complete
1dcc0eaaa3b9: Pull complete
ea3ed117f8b6: Pull complete
d1149d45769d: Pull complete
Digest: sha256:5d61520c6b3b8d77240398b32aeed34b3246fcc46e435bcd87bc09351bb6c295
Status: Downloaded newer image for

C:\Users\jnewcomb>docker run --name influxdb -p 8086:8086 ts=2020-11-30T11:30:17.619674Z lvl=info msg="Welcome to InfluxDB" log_id=0QnEXF_l000 version=2.0.2 commit=84496e507a build_date=2020-11-19T03:59:35Z
ts=2020-11-30T11:30:18.195636Z lvl=info msg=Listening log_id=0QnEXF_l000 transport=http addr=:8086 port=8086

And now I can now view this page in chrome:

I setup a login, password, MyOrgName and bucket using the web client - as stated in the getting started guide: “Set up InfluxDB through the UI”

Next step was getting a client to connect and run a simple command…
However, the C# client libraries I have tried always generate exception errors when I try to do anything ‘setup’ related, such as a client query to display available databases.
I believe the reason its not working is when I send the following query:
I get the following back:
{"code":"unauthorized","message":"unauthorized access"}

I believe I should get back

I tried setting up a default user (this time from the Docker CLI), but this didn’t seem to do anything. Restarted docker. Still unauthorized.
influx config create -n default -u http://localhost:8086 -o <MyOrgName> -t <token_created_for_admin_user_copy_pasted_from_client_WebUI> -a

Any tips or hint much appreciated… I also tried following this, but fell when it mentioned paths that dont exist in my setup.

Also I am also at a loss as to where docker stores InfluxDB files. The link above states:
I see a 4GB ‘DockerDesktop.vhdx’ file, but nothing else there…
When I run the ‘influx config’ command, I believe I’m modifying an influxdb.conf file… but where is this stored?
I looked in the Docker CLI and navigated around - etc, bin, lib, etc… I really don’t know where I’m looking!

Here I realise I have spent a day faffing doing no work and more pressing things get pushed my way…
It’s a shame, I really see the advantage of using influxDB to make the data we generate usable. Presently it’s just dumped to a local file which gets lost / ignored…
I feel I’m so close…

For the record…
This is how I’ve setup InfluxDB from the command line…
Pull influxdb2 to the local filesystem and create a new docker container from it (Run from cmd.exe)

docker pull
docker run --name influxdb -p 8086:8086

Then in the docker container CLI:
Setup the users, bucket and org names. (See ‘influx setup -h’)

influx setup --skip-verify --bucket sandbox --org MyOrgName --username administrator --password administrator --retention 0 --token UseThisToken_UseThisToken_UseThisToken_UseThisToken_UseThisToken_UseThisToken_UseThisT==

Then we need to add the token to /root/.influxdbv2/config file - otherwise we need to provide it for every request… (See ‘influx config create -h’)

influx config create --active --org MyOrgName --config-name administrator --host-url http://localhost:8086 --token UseThisToken_UseThisToken_UseThisToken_UseThisToken_UseThisToken_UseThisToken_UseThisT==

But still no luck, still getting 401 error…

Hi @jnewcomb, it looks like the C# libraries are still targeting the V1 APIs. InfluxDB 2.x includes compatibility APIs to handle those requests, but they require some extra up-front setup. We have some doc additions in the works (any suggestions would be appreciated), but in the meantime you’ll need to:

  1. Create a V1 compatibility auth token to use from your client library. You can do this using the influx v1 auth create command (reference docs here). The username/password you set with the command is what you should use to configure your client. Make sure to set --read-bucket and/or --write-bucket to enable interacting with your target bucket.
  2. Create a DBRP mapping for your target bucket. You can do this using the influx v1 dbrp create command (reference docs here). You can set anything you want for the --db and --rp arguments, and those are the values you’ll need to use when configuring your client. --bucket-id should point at your target bucket.

Please let me know if you’re still hitting issues after following those steps.

Many thanks for the useful pointer…
To set up a new container with V1 compatibility (I’ve tried to break it down into baby steps…)
a) Create a setup with admin user and org name with a primary bucket (If setting ‘–retention 0’ gives you and error set it to something like ‘–retention 52w’
influx setup --username administrator --password administrator --token MyTokenMyToken== --org MyOrgName --bucket sandbox --retention 0

b) I don’t seem to have any way of specifying the bucket ID… so I need to find out what it is. From this command, I find from here:

# influx bucket list
ID                      Name            Retention       Organization ID
af51c518b079e1c7        _monitoring     168h0m0s        1c49c5b0f4e4619f
c49c80722eb63f89        _tasks          72h0m0s         1c49c5b0f4e4619f
9b9841b1ecb10e16        sandbox         8736h0m0s       1c49c5b0f4e4619f <<--------

c) Next provide authorization for v1.x -> I tried this: (If specifying --password gives ‘Error: unknown flag’ error, remove it and set manually)
influx v1 auth create --read-bucket 9b9841b1ecb10e16 --write-bucket 9b9841b1ecb10e16 --username administrator --password administrator

d) Map the v1 database to the v2 bucket
influx v1 dbrp create --bucket-id 9b9841b1ecb10e16 --db sandboxDB --rp 0

e) To summarise so far…

# influx v1 auth list
ID                      Description     Name / Token    User Name       User ID                 Permissions
06b5ffe180d6a000                        administrator   administrator   06b5fa6c0816a000        [read:orgs/1c49c5b0f4e4619f/buckets/9b9841b1ecb10e16 write:orgs/1c49c5b0f4e4619f/buckets/9b9841b1ecb10e16]
# influx v1 dbrp list
ID                      Database        Bucket ID               Retention Policy        Default Organization ID
06b601d7a416a000        sandboxDB       9b9841b1ecb10e16        0                       true    1c49c5b0f4e4619f

Back to the Vibrant C# client - When doing a simple database ‘list’ command I see the newly linked ‘sandboxDB’ - success!
However - any operation on ‘sandboxDB’ returns a server error.
I’m surprised none of the settings above have appeared in the /root/.influxdbv2/configs file. Where does this stuff go - if not in configs?
Any nudge in the right direction welcome… I’m sure its easy when you know how. Oh well, back to work!

Additional comments:
I see there are some recent commits on this… So I follow the download nightly instructions for 2.x:
docker pull

Which gets me this: IN USE nightly b8c6c4f59e84 19 minutes ago 275.55 MB

I add the image to the container using this:
docker run --name influxdb -p 8086:8086

But suprisingly, checking the version gives me this:

# influx -version
InfluxDB shell version: 1.7.0~n201901110800
Enter an InfluxQL query

I guess using the nightly build system is just not for me!
Back to the 2.0.2 release instead…

I’m surprised the nightly is running such an old version, I’ll open an issue about it.

Do you see any useful logs from the influxd process when you hit the server errors?

I believe only influx setup writes to /root/.influxdbv2/configs, everything else is stored by the influxd process. I’d still expect that data to end up in /root/.influxdbv2, so you see any other files in that directory, i.e. an influxd.bolt?

Also, for you / anyone else watching: --password on v1 auth create and --retention 0 on setup will both work in the upcoming 2.0.3 release :smiley:

Hi , i have found the solution work for me , you need to create auth v1 api , its additionnal auth whenever you have already the user déclared in influx:

if you use influx v1 auth list you can verify this list is null
after influx v1 dbrp ls catch the id of your bucket you want query
and create the auth with influx v1 auth create --username "USERNAME" --password "PASSWORD" --read-bucket BUCKET_ID

Now you can send request in InfluQL to the influxDB 2.X

i work on influxDB 2.2.0

Ressource: Use Grafana with InfluxDB OSS | InfluxDB OSS 2.0 Documentation

Tell me if this response help you.