influxdata / influxdb

Scalable datastore for metrics, events, and real-time analytics
https://influxdata.com
Apache License 2.0
28.98k stars 3.56k forks source link

Connecting to Grafana - InfluxDB Error: Bad Request #20761

Open C-monC opened 3 years ago

C-monC commented 3 years ago

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?

danxmoran commented 3 years ago

@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:

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.

C-monC commented 3 years ago

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

danxmoran commented 3 years ago

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

danxmoran commented 3 years ago

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?

BecsLutton commented 3 years ago

Any update on this? Having same issue.

msiemers commented 3 years ago

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

weltenbeweger commented 3 years ago

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

arnljot commented 2 years ago

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.

alexplex commented 2 years ago

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 ) I'm still getting a Bad Request error.

image

aschmelyun commented 2 years ago

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.

sanderson commented 2 years ago

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

iimamudd commented 2 years ago

Issue resolved for me as well

Format will be like : Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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

hzlRises commented 2 years ago

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

牛逼!

shojaeix commented 2 years ago

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

xiaofengzs commented 2 years ago

@hzlRises 确实牛逼!

cun commented 2 years ago

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.

EasternPA commented 2 years ago

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

lisaxiaoli commented 1 month ago

I set header correctly, but I can not get the data of block propatation,transaction processing and transaction propagation. F12 error on the page is as follows: Failed to load resource: the server responded with a status of 400 (Bad Request)

bbb

![Uploading aaa.png…]()