influxdb icon indicating copy to clipboard operation
influxdb copied to clipboard

Connecting to Grafana - InfluxDB Error: Bad Request

Open C-monC opened this issue 4 years ago • 18 comments

Hi,

I am trying to view Influxdb2 data in Grafana. I use a python script to upload data into influxdb. This is confirmed to be working: image

Influxdb is running on the IP shown in the image above. When I try to connect Grafana I get the error IInfluxDB Error: Bad Request

Following the steps in the documentation the url I input into grafana is the same one as in the image above. image

The rest of the config is shown in the image below. Both passwords are the admin token and the database is my bucket ID.

image

Has anyone managed to get a minimum example working between Grafana and Influxdb2 or is there an obvious step I'm missing?

  • System info: Linux 5.4.0-65-generic x86_64
  • InfluxDB version: 2.0.4

C-monC avatar Feb 16 '21 13:02 C-monC

@C-monC I'm not familiar with the Grafana integration, but based on similar issues I've seen I'd recommend trying the instructions I listed at https://github.com/influxdata/kapacitor/issues/2476#issuecomment-775988436 to expose your bucket via our V1 compatibility APIs. You'd then use:

  • Database: name of the database you set for your DBRP resource
  • Username: name you set for your V1 user
  • Password: password you set for your V1 user

If that works for you, could you confirm here? I'll make sure the Grafana-InfluxQL docs get updated to match the steps that work.

danxmoran avatar Feb 18 '21 02:02 danxmoran

I've tried those steps - not sure which parameters must reference new objects and which should be new ones. For instance. influx v1 dbrp create --org kubOrg --db testdb --rp rp --bucket-id d025cfae0bd77b14 -t asgsgsdfg --db and --rp would be initialized by that name? Could not find a place to create them in the gui. The bucket is a bucket I've already made.

influx v1 auth create --org kubOrg --username test --password testtest --write-bucket d025cfae0bd77b14

Creating the token does not create a token in the gui but it does return a column which says "name/token"

ID Description Name / Token User Name User ID Permissions

In grafana I then add the datasource. Password testtest image

The rest of the configuration - password is again testtest: image

C-monC avatar Feb 18 '21 07:02 C-monC

What happens if you switch "HTTP Method" to "POST"? We've seen strange failures when using GET (#20713)

danxmoran avatar Feb 18 '21 13:02 danxmoran

If you have control over the server deployment, you could also run influxd --log-level debug to (hopefully) get some tracing logs on the server-side. If switching the HTTP Method doesn't work, could you paste any logs you can find here?

danxmoran avatar Feb 18 '21 13:02 danxmoran

Any update on this? Having same issue.

BecsLutton avatar Jul 09 '21 13:07 BecsLutton

I have the same issue. Is there any newer Information?

msiemers avatar Aug 21 '21 08:08 msiemers

Use Custom HTTP Header an not "Basic auth" Header = "Authorization" Value ="Token <yourToken>" important is the Space between the Word Token and your Token.

Found on http://wiki.webperfect.ch/index.php?title=InfluxDB_2.x:_Error:Bad_Request(Grafana_and_InfluxQL)&oldid=2578

weltenbeweger avatar Aug 28 '21 23:08 weltenbeweger

Use Custom HTTP Header an not "Basic auth" Header = "Authorization" Value ="Token " important is the Space between the Word Token and your Token.

Found on http://wiki.webperfect.ch/index.php?title=InfluxDB_2.x:_Error:Bad_Request(Grafana_and_InfluxQL)&oldid=2578

I can confirm that this also fixed it for me. The token is created or copied from influxdb web console, then added as a custom http header in grafana datasource config as per instructions on the link above.

arnljot avatar Dec 08 '21 19:12 arnljot

Use Custom HTTP Header an not "Basic auth" Header = "Authorization" Value ="Token " important is the Space between the Word Token and your Token. Found on http://wiki.webperfect.ch/index.php?title=InfluxDB_2.x:_Error:Bad_Request(Grafana_and_InfluxQL)&oldid=2578

I can confirm that this also fixed it for me. The token is created or copied from influxdb web console, then added as a custom http header in grafana datasource config as per instructions on the link above.

This didn't work for me. After generating a token and pasting it in Custom HTTP Headers with the right format (space between "Token" and <My_Token>) I'm still getting a Bad Request error.

image

alexplex avatar Feb 17 '22 15:02 alexplex

Use Custom HTTP Header an not "Basic auth" Header = "Authorization" Value ="Token " important is the Space between the Word Token and your Token.

Found on http://wiki.webperfect.ch/index.php?title=InfluxDB_2.x:_Error:Bad_Request(Grafana_and_InfluxQL)&oldid=2578

I was having the exact same issue and this fix also worked for me. I also continued using the GET http method, not sure if that had anything to do with it.

aschmelyun avatar Mar 02 '22 08:03 aschmelyun

The process for connecting Grafana to InfluxDB 2.x and using InfluxQL is documented here: https://docs.influxdata.com/influxdb/v2.1/tools/grafana/?t=InfluxQL

sanderson avatar Mar 02 '22 16:03 sanderson

Issue resolved for me as well

Format will be like : Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Note: You have to write token space and then actual token value

iimamudd avatar Apr 21 '22 08:04 iimamudd

Use Custom HTTP Header an not "Basic auth" Header = "Authorization" Value ="Token " important is the Space between the Word Token and your Token.

Found on http://wiki.webperfect.ch/index.php?title=InfluxDB_2.x:_Error:Bad_Request(Grafana_and_InfluxQL)&oldid=2578

牛逼!

hzlRises avatar May 14 '22 14:05 hzlRises

You can also roll back to v1.8.4 to fix this problem. https://stackoverflow.com/a/66732230/8712494

shojaeix avatar Jun 07 '22 07:06 shojaeix

@hzlRises 确实牛逼!

xiaofengzs avatar Jun 27 '22 09:06 xiaofengzs

Use Custom HTTP Header an not "Basic auth" Header = "Authorization" Value ="Token " important is the Space between the Word Token and your Token.

Found on http://wiki.webperfect.ch/index.php?title=InfluxDB_2.x:_Error:Bad_Request(Grafana_and_InfluxQL)&oldid=2578

You absolute legend!!! Thank you! That space makes complete sence, just annoying how the value is star'd out so you think it's just the API key it required! "header" "token api_key" with a space. You sir, are amazing.

cun avatar Jul 11 '22 17:07 cun

Wow, I'm shocked this worked. Great job.

EasternPA avatar Jul 23 '22 15:07 EasternPA

Does that impossible to fix this error? Just like 💩!

helloworlde avatar Feb 18 '23 14:02 helloworlde