Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating InfluxQL Datasource to InfluxDB v2 returns Unauthorized(401) or InfluxDB Error: Bad Request #29372

Closed
eaglejohn81 opened this issue Nov 25, 2020 · 5 comments

Comments

@eaglejohn81
Copy link

eaglejohn81 commented Nov 25, 2020

What happened:
After setup a clean GA version of InfluxDB 2.0.2, I created a dbrp mapping according
https://docs.influxdata.com/influxdb/v2.0/query-data/influxql/#map-unmapped-buckets and trying to create a Grafana datasource to the InfluxDB database according https://docs.influxdata.com/influxdb/v2.0/tools/grafana/.

This fails with "Unauthorized(401)" on Grafana 7.1.5 or "InfluxDB Error: Bad Request" on Grafana 7.3.4.

According the nginx access log, this query is executed (same for both cases, returning 401):

{ip} - influxdb [25/Nov/2020:11:26:14 +0000] "GET /query?db=30days&epoch=ms&q=SHOW+RETENTION+POLICIES+on+%2230days%22 HTTP/1.1" 401 48 "-" "Grafana/7.3.4"

When running this query using postman, I do get correct results:

curl --location --request GET 'http://myinfluxhost/query?db=30days&epoch=ms&q=SHOW+RETENTION+POLICIES+on+%2230days%22' \
--header 'Content-Type: application/json' \
--header 'Authorization: Token {Token}'

{"results":[{"statement_id":0,"series":[{"columns":["name","duration","shardGroupDuration","replicaN","default"],"values":[["30days","0s","168h0m0s",1,true]]}]}]}

Environment:

  • Grafana version: 7.1.5 and 7.3.4
  • Data source type & version: InfluxDB
  • OS Grafana is installed on: AWS Linux
  • User OS & Browser: Windows/Firefox
  • InfluxDB: v2.0.2
@eaglejohn81
Copy link
Author

Solution is to provide a header "Authorization" in the datasource:

image

This should contain the value: "Token {token}"

This is not described in the documentation (https://docs.influxdata.com/influxdb/v2.0/tools/grafana/), so I leave it open as a documentation issue.

@aocenas
Copy link
Member

aocenas commented Nov 26, 2020

@eaglejohn81 if this is an issue in Influx docs you should create an issue with Influx as we are not responsible for maintaining that.

@dwilliss
Copy link

When you say the header should have a value of "Token {token}", are the curly brackets { } part of the string?
I've tried both ways and neither work, but I'm not sure if I have other settings correct either.
I don't know what to do about database, username and password since none of those apply to Influxdb 2, so I have left them blank.
I'm assuming "database" is the org, but maybe I'm wrong

@dwilliss
Copy link

dwilliss commented Mar 25, 2023

Just got it to work. The {} is not part of the string.
I had to turn off Basic Auth which was still on from before I upgraded to Influxdb 2
Database is in fact the bucket name.
Leave Username and password blank.

@AndreKR
Copy link

AndreKR commented Mar 11, 2024

@aocenas This is an issue with the InfluxDB data source in Grafana. When configured for query language Flux it will correctly ask for a token, but when configured for query language InfluxQL the field is missing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants