Trouble Adding InfluxDB 2.0 as DataSource

Noob alert!.
I have 2 ubuntu 20.04 LXCs in proxmox running Influx 2.0 and Grafana. Influx receives data via telegraf agents running a bunch of windows/linux boxes. I’m trying to add this influx db as a datasource in Grafana but it doesnt seem to work. I’m not sure what I’m missing here.

If there anything that I need to do in Influx 2.0 to allow connections from Grafana?

Used the default token that was created when influx is setup. Tried both Org name and id. Tried switching buckets. Nothing seems to eowk.

Grafana Screenshot

Influx 2.0 buckets list

Hi there,
also noob alert ahead - i’v got the same problems.
I run a local server with Influx 1.0 and Grafana. This works very well. For my devices, especially the portable ones, I use an InfluxDB 2.0 cloud instance (azure). But I simply can’t integrate it due to the same problem.
Bucket names match, but always “error reading influxdb”

Any Ideas?

I started with Influxdb azure instance as well and failed to integrate with grafana, so I thought I’ll set it up influx locally. That apparently did not help. Is it possible that any of grafana/influx ports must be open to get this to work? Also @anon8940081 - any idea on log files that may have been created to debug what caused the connection failure?

Have added the HTTP request payload and response that I see after clicking “Save & Test”. Would be great if someone can read this and help us troubleshoot the problem. I also checked the log file in /var/log/grafana, but that doesnt seem to indicate any error establishing this connection.

Request Payload

{"datasource":{"id":1,"orgId":1,"name":"InfluxDB","type":"influxdb","typeLogoUrl":"","access":"proxy","url":"http://influx.cosmos:9999/api/v2","password":"","user":"","database":"","basicAuth":true,"basicAuthUser":"","basicAuthPassword":"","withCredentials":false,"isDefault":true,"jsonData":{"defaultBucket":"temp","httpMode":"POST","organization":"Infiverse","version":"Flux"},"secureJsonFields":{"token":true},"version":16,"readOnly":false},"id":1,"message":"Datasource updated","name":"InfluxDB"}

Response

{"results":{"test":{"error":"parse error on line 1, column 1: bare \" in non-quoted-field","refId":"test","series":null,"tables":null,"dataframes":null}},"message":"parse error on line 1, column 1: bare \" in non-quoted-field"}

Hi @rajivvishwa
i just checked my cloud instance but found no section to get a log or something. So understanding the problems seems to need either the influxdata support or a local instance.
If we get your local influxdb working that should also work for cloud.

I played around with Influx 2.0 REST API and it seems to work correctly with POSTMAN client. I’m guessing that the issue is with Grafana in our case. The HTTP response I posted earlier is returned by Grafana API, so I believe something weird is going on there. Surprised how we are the only ones with this issue.

{"results":{"test":{"error":"parse error on line 1, column 1: bare \" in non-quoted-field","refId":"test","series":null,"tables":null,"dataframes":null}},"message":"parse error on line 1, column 1: bare \" in non-quoted-field"}

The connection URL should be http://localhost:9999 instead of http://localhost:9999/api/v2.

I picked the api endpoint from grafana + influx 2.0 docs here - https://docs.influxdata.com/influxdb/v2.0/tools/grafana/. It looks like someone updated it just now with the correct URL format.

1 Like

Hi @rajivvishwa did you have success configuring your data source?

Hi, I have the same Problem with connecting to https://eu-central-1-1.aws.cloud2.influxdata.com/api/v2

have you resolve the problem, I have the same when using influxDB cloud.

I got it to work for me finally. I had to use the HTTP Header “Authorization” and the value was “Token WHATEVERYOURAPITOKENIS”. User for the database was the ID under Organization>About>My User ID

2 Likes

How about the password. Mine still failed connected to Grafana.

no luck for me either. based on the form parameters grafana should be correctly supporting Influx 2.0, so adding organization and token should be sufficient to authorize without the need to fiddle with HTTP headers.

however when looking into the logs of influxdb it shows the following:

ts=2021-03-14T11:52:08.653580Z lvl=info msg=Unauthorized log_id=0SsKDZXW000 error="token required"

so it seems as if grafana would not pass the token to influxdb for some reason. this happens when i pass the token in the InfluxDB details field or as an auth header.

Has it been solved? this problum

I have written a guide for everyone who wants to setup Influxdb v2 with InfluxQL

@familiepiroth If you want to setup Influxdb v2 with Flux, you need to change url to just https://eu-central-1-1.aws.cloud2.influxdata.com/ and then for organization, use the org id that can be find in the url. See below my example:

2 Likes

thanks, that was the crucial part. maybe it should have been made more clear that the configuration expects organization id and not organization name

3 Likes

Yeah, I also confirm that this is the crucial part of the puzzle!
image

After specifying the ID instead of the name as implied by the description

It is connected well

Thanks. This solved it for me.

Dear, I followed all of this without success, is it linked to the fact that I am using docker?
Br.