Troubleshooting
Grafana InfluxQL on InfluxDB 2 fails: use the Token header
Short answer
On InfluxDB 2, a Grafana InfluxQL panel fails with Bad Request while the server log records Unauthorized and authorization not found: a 2.x token typed into the Basic Auth username and password fields is not recognized on the compatibility query path. Send the token in a custom Authorization header whose value is the word Token, a space and the token string, verified on InfluxDB OSS 2.0.2 with Grafana 7.3.3. The DBRP mapping is a separate checkpoint and needs no change.

On this page
Grafana's Bad Request on an InfluxQL panel is only a generic symptom. The fault sits one step away, in the InfluxDB server log: an Unauthorized entry whose error field reads authorization not found. On InfluxDB 2 that text means the server did not recognize the credential at all, and the usual reason is the credential's format: a 2.x token typed into the Basic Auth username and password fields of the data source. The fix, verified on InfluxDB OSS 2.0.2 with Grafana 7.3.3, is to drop Basic Auth and send the token in a custom HTTP header whose value is the word Token, a space, then the token string. The DBRP mapping you already validated stays untouched; it is a separate checkpoint.
Read the server log, not the panel banner #
When a panel shows Bad Request, Grafana is passing along a generic client-side failure; it is not the diagnosis. Correlate the request time with the InfluxDB server log and look for an info-level Unauthorized line whose error field reads authorization not found. That pairing tells you the server never recognized the credential:
| Observation | What it means | What to do |
|---|---|---|
| Panel: Bad Request | Generic message passed up by Grafana | Correlate the time with the server log |
| Log: Unauthorized | The request failed authentication | Check how Grafana formats the credential |
Log: authorization not found |
The credential itself was not recognized | Fix the header format below |
The same authorization not found text on the Telegraf write path has a different cause chain, covered in the Telegraf-side fix for authorization not found on InfluxDB 2 (article:fix-telegraf-authorization-not-found-on-influxdb-2). The query path discussed here authenticates separately from the write path, so fixing one never fixes the other.
Why the username and token pair fails #
InfluxQL against InfluxDB 2 rides the 1.x compatibility query API, and that path recognizes exactly two credential forms: an Authorization header carrying the token with the Token scheme, or a username and password pair that is a compatibility credential created with influx v1 auth create. A 2.x token is neither. Typed into the Basic Auth password field, it does not match a compatibility password, so the server answers authorization not found — even while the same token lists your DBRP mapping without trouble. That is why a passing mapping test proves nothing about the query path.
The write side has the mirror-image trap, a v1 output sending Basic Auth at a 2.x server and failing the same way, covered in why the Telegraf 401 comes from the v1 output on InfluxDB 2.
Send the token in the Authorization header #
Fix the data source:
- Open the InfluxDB data source whose query language is set to InfluxQL.
- Switch off Basic Auth and clear the username and token you typed into those two fields.
- Add a custom header with the key
Authorization. - Set its value to
Token <token>: the word Token with a capital T, which is case-sensitive, exactly one space, then the token string. - Save and re-run the panel query; data should return and the log should gain no new Unauthorized line.
Scope that token to read the buckets behind the dashboards; the query path needs no write permission.
Prove it with two requests #
You can reproduce and fix the fault before touching Grafana. The example uses a host at 192.168.1.50 (substitute your own instance; the bracketed port stands for the port it listens on), an example database plcdata — the database name of the DBRP mapping — an example measurement line_speed, and EXAMPLE_TOKEN as a stand-in for your token:
# 1. Fails: the token sent as a Basic Auth password
curl -G "http://192.168.1.50:<port>/query" \
--data-urlencode "db=plcdata" \
--data-urlencode "q=SELECT last(value) FROM line_speed" \
-u "anyuser:EXAMPLE_TOKEN"
# 2. Works: the same token in the Authorization header
curl -G "http://192.168.1.50:<port>/query" \
--data-urlencode "db=plcdata" \
--data-urlencode "q=SELECT last(value) FROM line_speed" \
-H "Authorization: Token EXAMPLE_TOKEN"
Request 1 returns an Unauthorized (401) response and adds a fresh authorization not found line to the log — the reported symptom reproduced. Request 2 returns a JSON body with the last line_speed value and its timestamp, and the log stays clean. Same endpoint, same token, only the credential format differs: that is the test that proves the fix.
Keep the mapping check separate from authentication #
The DBRP mapping maps a 1.x database and retention policy pair onto a 2.x bucket, and InfluxQL on 2.x cannot run without it; the steps are in DBRP mapping configuration for Grafana InfluxQL. It is still a second, independent checkpoint:
- Mapping: request the mapping list with your token and confirm the pair, for example database
plcdataonto your bucket, is present. - Authentication: the query request must arrive with the Authorization header in Token form, as proven above.
A mapping that lists correctly says nothing about the header, and a correct header says nothing about the mapping. Fix the header while the log says authorization not found; only when the log is clean and the panel still returns nothing do you check that the query's database name matches the mapping.
The decision #
- The log says
authorization not found: the credential format is wrong. Remove Basic Auth, add theAuthorization: Token <token>header, and the query path is repaired. - The client cannot send custom headers: create a compatibility username and password with
influx v1 auth createand use that pair instead; a token in the password field will never authenticate on this path. - Header fixed, log clean, panel still empty: the fault is downstream — the mapping or the database name in the query — not authentication.
- Dashboards written for InfluxDB 1.x: keep InfluxQL. The mapping exists so those panels run against 2.x buckets; do not rewrite them in Flux to escape an authentication error.
Questions asked
Is the Token prefix case-sensitive in the Authorization header?
Yes. The value must begin with the word Token with a capital T, followed by exactly one space and the token string. Writing bearer in place of Token, or a lowercase token, reproduces the authorization not found failure, so treat the scheme word as fixed text, not a label.
Does this fix apply to newer Grafana and InfluxDB releases?
The documented case is InfluxDB OSS 2.0.2 with Grafana 7.3.3, and the same header fix is reported for InfluxDB 2.0.3 with Grafana 8.3.3. Grafana's current troubleshooting documentation still tells InfluxQL users on InfluxDB 2.x to verify that the token sits in an Authorization header with the Token prefix, so apply the same setting on later releases.
Should I rewrite my dashboards in Flux instead?
No. Dashboards built for InfluxDB 1.x keep working through the DBRP mapping, which exists so InfluxQL queries run against 2.x buckets. Changing query language to dodge an authentication error would rewrite every panel for nothing; fix the header and keep the dashboards as they are.
Why do older guides show Basic Auth working?
Those guides target InfluxDB 1.x, where a username and password is the native scheme. On 2.x the InfluxQL path rides the 1.x compatibility API, which accepts either the Token header or a compatibility username and password created with the influx v1 auth create command, never a token typed into the password field.


