bb-Ricardo / fritzinfluxdb

Writes data from fritzbox to influxdb
MIT License
144 stars 36 forks source link

FRITZ!Box Router Status dashboard broken in Grafana v11.1.0 #123

Closed Aldjinn closed 2 months ago

Aldjinn commented 3 months ago

Hey, I've been using your project for a long time now without any issues, many thanks for that.

But after upgrading my Grafana to v11.1.0, the FRITZ!Box Router Status dashboard seems to be broken. The other three ones are still working fine.

Grafana v10.4.5: Grafana-v10 4 5

Grafana v11.1.0: Grafana-v11 1 0

I'm not sure if the issue could related to this, because the other three still working dashboards show it as well. influxdb

I've tested with Firefox 127.0.2 and Edge 126.0.2592.81, both show the same behavior.

falke9176 commented 3 months ago

I see the difference. It may be that something has changed in the variables in Grafana that is also different from the other dashboards.

You cannot select the FritzBox - it only shows "None".

image

Aldjinn commented 3 months ago

That's correct, @falke9176. The FritzBox is not selectable.

xyrolaith commented 3 months ago

The backend error from Grafana might be more helpful. Unfortunately I do not have any Flux query knowledge to fix it myself.

grafana-server[1449775]: logger=tsdb.influx_flux endpoint=queryData pluginId=influxdb dsName="InfluxDB FritzBox" dsUID=wUjJE6-4z uname=admin t=2024-07-03T12:19:17.16378475+02:00 level=warn msg="Flux query failed" err="invalid: error in building plan while starting program: cannot query an empty range" query="from(bucket: \"fritzbox\")\n |> range(start: 1970-01-01T00:00:00Z, stop: 1970-01-01T00:00:00Z)\n |> filter(fn: (r) => r._measurement == \"fritzbox\" and r._field == \"linkuptime\")\n |> keyValues(keyColumns: [\"box\"])\n |> group()\n |> keep(columns: [\"box\"])\n |> distinct(column: \"box\")"

I am also unsure if the invalid query is from the dashboard variable settings (boxtag) or from one of the panels.

Aldjinn commented 3 months ago

That's the query in the dashboard:

from(bucket: v.defaultBucket)
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r._measurement == "$measurement" and r._field == "linkuptime")
  |> keyValues(keyColumns: ["box"])
  |> group()
  |> keep(columns: ["box"])
  |> distinct(column: "box")
falke9176 commented 3 months ago

Something is wrong with getting the value for the variable boxtag

f.e. this is the JSON Code of Table "FritzBox Info":

from(bucket: v.defaultBucket)
  |> range(start: -1d)
  |> filter(fn: (r) => r._measurement == "${measurement}" and r.box == "${boxtag}" and
    (
      r._field == "external_ip" or
      r._field == "external_ipv6" or
      r._field == "ipv6_prefix" or
      r._field == "ipv6_prefix_length" or
      r._field == "model" or
      r._field == "serialnumber" or
      r._field == "softwareversion" or
      r._field == "last_auth_error" or
      r._field == "myfritz_host_name"
    ) 
  )
  |> last()
  |> toString()
  |> drop(columns: ["box", "_measurement", "_start", "_stop", "_time"])
  |> map(fn: (r) =>  ({
        r with _field:
          if r._field == "external_ip" then "IPv4"
          else if r._field == "external_ipv6" then "IPv6"
          else if r._field == "ipv6_prefix" then "IPv6 Prefix"
          else if r._field == "ipv6_prefix_length" then "IPv6 Prefix Length"
          else if r._field == "model" then "Model"
          else if r._field == "serialnumber" then "Serial"
          else if r._field == "softwareversion" then "SW Version"
          else if r._field == "last_auth_error" then "Last Auth Error"
          else if r._field == "myfritz_host_name" then "MyFritz Hostname"
          else r._field
        })
      )

and the Query Inspector of Grafana for that panel shows this:

from(bucket: "fritzbox")
  |> range(start: -1d)
  |> filter(fn: (r) => r._measurement == "fritzbox" and r.box == "" and
    (
      r._field == "external_ip" or
      r._field == "external_ipv6" or
      r._field == "ipv6_prefix" or
      r._field == "ipv6_prefix_length" or
      r._field == "model" or
      r._field == "serialnumber" or
      r._field == "softwareversion" or
      r._field == "last_auth_error" or
      r._field == "myfritz_host_name"
    ) 
  )
  |> last()
  |> toString()
  |> drop(columns: ["box", "_measurement", "_start", "_stop", "_time"])
  |> map(fn: (r) =>  ({
        r with _field:
          if r._field == "external_ip" then "IPv4"
          else if r._field == "external_ipv6" then "IPv6"
          else if r._field == "ipv6_prefix" then "IPv6 Prefix"
          else if r._field == "ipv6_prefix_length" then "IPv6 Prefix Length"
          else if r._field == "model" then "Model"
          else if r._field == "serialnumber" then "Serial"
          else if r._field == "softwareversion" then "SW Version"
          else if r._field == "last_auth_error" then "Last Auth Error"
          else if r._field == "myfritz_host_name" then "MyFritz Hostname"
          else r._field
        })
      )

So I changed the "boxtag" to the right Boxname-Value - and all tables of this dashboard are shown the results.

mmmhh I'm not so deep fit in Grafana .......

bb-Ricardo commented 3 months ago

Hi, Seems like Grafana broke the dashboard again. Have you tried reimporting it. This worked in the past.

Aldjinn commented 3 months ago

Yes, I already tried to reimport it. But unfortunately without success.

stepman0 commented 3 months ago

In the other dashboards, "fritz.box" is also not shown, only the option "all": image

I tried adding all to the variable in the FRITZ!Box Router Status dashboard, but no values are shown: image

Real-Slice commented 2 months ago

Hello all, I had the same problem and found one working solution for me. Open the FRITZ!Box Router Status Dashboard, go to Dashboard Settings, then Settings-Variables and edit the boxtag Variable. Scroll down to Select Options and select Include All option and write in the field Custom all value: fritz.box Then Run query and Apply custon all value After this when you open the Dashboard again, it will automatically load it.

bb-Ricardo commented 2 months ago

I currently don't have access to an influxdb 2 instance. Can someone take the influx query for the variable and run it in the influxdb 2 UI? If it works there then Grafana might have an issue.

joos2k commented 2 months ago

I had the same problem after upgrading Grafana. This is a Grafana problem with InfluxDB. It was introduced in Grafana 11.1. A fix is ready, but I think a new version was not released yet.

https://github.com/grafana/grafana/issues/88983

bb-Ricardo commented 2 months ago

@joos2k, great finding, thank you.

I tried to upgrade to Grafana 11.1 and it wouldn't even show a login prompt anymore, so I had to downgrade to 10 again. 🤷‍♂️

JF62 commented 2 months ago

There's a know bug in Grafana itself. Until it's fixed you can change the Variable boxtag query by yourself to following:

from(bucket: v.defaultBucket) |> range(start: ${from:date}, stop: ${to:date}) |> filter(fn: (r) => r._measurement == "$measurement" and r._field == "linkuptime") |> keyValues(keyColumns: ["box"]) |> group() |> keep(columns: ["box"]) |> distinct(column: "box")

joos2k commented 2 months ago

A fixed Grafana version has now been released. This problem no longer occurs for me with Grafana 11.1.1.

Aldjinn commented 2 months ago

Nice, I can confirm that the dashboard is running fine with Grafana v11.1.1.

grafik grafik

bb-Ricardo commented 2 months ago

Great. Thank you for reporting back.

Then Inwill close this issue.