Integration with InfluxDB - InfluxQL; Error: BadRequest

Hi,
I’m using Grafana Cloud and InfluxDB Cloud

On Grafana - I’m creating datasource connection

Details used for creating connection string
Query Language: InfluxQL
URL: https://us-central1-1.gcp.cloud2.influxdata.com
Basic Auth
Username: xxxxx@gmail.clom
Password: I created a token and used it.
Forwarded OAuth

Error: BadRequest… Not sure what is wrong…
Appreciate all the help I can get…

Hello @proxybon for cloud2, the user in InfluxDB Details on the bottom should be id of the organisation. So for example, in my case (see below) it is bbefc202024380d0. And the database is the default bucket.

Thanks @ivanahuckova
Still the same… I even tried adding header but the error continues to be same…
Added Header and tried based on this link

Would you try to switch User in BasicAuth to the users (your) email? And for password keep the generated token. I don’t think you need Custom HTTP Header. And then in InfluxDB details, database is the bucket’s name, user is the org id and password is the token.

Also, I tested/tried this based on this documentation directly from InfluxDB on API compatibility of InfluxDB2 with InfluxDB1: InfluxDB 1.x compatibility API | InfluxDB OSS 2.0 Documentation. Generally for cloud2, setting up with Flux is much easier and more straight forward, as you can see there clearly what is expected:

Thanks @ivanahuckova

InfluxDB Details

OrgId as UserName: 1d83c00978b444fe
Token:
HTTP Method: Get

Removed - Header…

But still same error… :frowning:

Would you mind trying it at your end… I will create a temp token and share it… just to isolate that its not me :slight_smile:

So just 1 last check if we have everything configured in the same way:
Basic Auth:
User: your user id (but not the id number, the user id name) that you can find in /about
Password: active token created in load-data/tokens that has access to specified bucket

InfluxDB Details:
Database: name of you InfluxDB bucket that you want to use in load-data/buckets. Keep in mind, provided token has to have read access to that bucket.
User: org id that can be found in /about
Password: active token created in load-data/tokens that has access to bucket

Again… thanks for holding on.

I have created using Flux - this works brilliant and I’m able to query it.

InfluxQL… Datasource connected but doesn’t show any database…
Reason why I wanted to use InfluxQL is to use my exisiting SQL skills…

Here’s what i tried


Fiddler details


Same when I try with Flux it shows that it found 3 buckets

Oh yeah! That’s good! :tada:So there is 1 last thing we need to do and then it is going to work. In InfluxDB2 we have buckets. In influxDB1 it is databases. You can learn more here:
https://docs.influxdata.com/influxdb/v2.0/query-data/influxql/

So to be able to query buckets, you have to map unmapped buckets:
https://docs.influxdata.com/influxdb/v2.0/query-data/influxql/#map-unmapped-buckets

I just ran this in my terminal:

curl --request POST https://eu-central-1-1.aws.cloud2.influxdata.com/api/v2/dbrps \
  --header "Authorization: Token InputYourToken" \
  --header 'Content-type: application/json' \
  --data '{
        "bucketID": "05c452b464dbb000",
        "database": "arduino",
        "default": true,
        "orgID": "bbegc202024380d0",
        "retention_policy": "30d"
      }'

Thanks for helping me sail this far but I might need a little more before I cross the “Hello World”

I installed Curl > “Crash course CURL” >tested with GET Verb and it worked fine
then I ran the script to map but its throwing error “Unauthorized…”

Checks

  • I checked the token, it has access to all the buckets
  • I cross verified all the Id’s like BucketId and OrgId they are good
  • I checked Curl - its installed correctly since it responsed with HTML for Get verb…
  • Check Grafana dashboard and same error “Database not found” - Since it not mapped yet.


Not sure where am I going wrong… My guess is my token is not getting passed

For Authorization header, it needs to have word “Token” in front of it. Sorry I missed it in my example above (I have added it now, so if anyone is looking to do the same, there is complete info).

so something like --header "Authorization: Token hXzWOGsHXW6uM0NdsnksnqDjtPzdmldmlwJUZ4G-LDsLXJ1y1twpE1LS,mdlmdsLkcA==" \

Thanks @ivanahuckova :hugs: Its all working… finally…
Many thanks!

1 Like

Yaaay! :tada: Glad to hear that.

@proxybon I have written down this blog post on Setting up InfluxDB v2 (Flux) with InfluxQL in Grafana and while working on it, I’ve learned that you actually just need to fill out Database - default_bucket and Password - token fields and it should still work without any problems. So no username, company id and tokens added multiple times are necessary. Sorry for overcomplicating my advice, but that’s how I had it before I started to document it in blog post.