InfluxDB: Flux unauthorized access

  • What Grafana version and what operating system are you using?
    Grafana: v11.1.0
    Hosted on Docker

  • What are you trying to achieve?
    Use data from InfluxDB database on mostly time series charts

  • How are you trying to achieve it?
    Create a Time series chart and add a custom Query via Flux syntax.

  • What happened?
    Most of the time, I get “Status: 500. Message: unauthorized: unauthorized access”, but not always.
    I have 6 graphs on a dashboard from the influx database, most of the time all are empty and shows the above errors.
    Sometimes only half of them showing it, sometimes all seems to work until I refresh it 1-2 times.

  • What did you expect to happen?
    This worked before correctly when I configured these dashboards / graphs.
    First I thought this is really an authorization issue, because we switched from local auth to SSO.
    However, same issue happens with a temporary local account as well.
    Sometimes, even in the “Connections” tab when I press Save&Test, it says unathorized access, but most of the time, it shows “datasource is working”.

The Token used by grafana has all permissions in influx.
Other datasources (mysql) works correctly.

  • Can you copy/paste the configuration(s) that you are having problems with?
    Example query:
from(bucket: "log")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["_measurement"] == "uptime" and r["key"] == "${device:text}" and r["_field"] == "uptime")
  |> aggregateWindow(every: duration(v: int(v: ${interval}) * 100), fn: mean, createEmpty: false)
  |> map(fn: (r) => ({ time : r["_time"], "Uptime" : r._value}))