daq-tools / kotori

A flexible data historian based on InfluxDB, Grafana, MQTT, and more. Free, open, simple.
https://getkotori.org/
GNU Affero General Public License v3.0
107 stars 17 forks source link

Grafana: Only permit numeric fields to be established on Graph panels #126

Closed amotl closed 1 year ago

amotl commented 1 year ago

Hi again,

when testing GH-125 in production, we discovered at ^1 that Grafana would croak on non-numeric fields being established on the Graph panel. They will make the panel croak like InfluxDB Error: unsupported mean iterator type: *query.stringInterruptIterator or InfluxDB Error: not executed [^2].

image image

While the ecowitt2mqtt decoder strips all text fields like PASSKEY, stationtype, and model from the original data, it adds a few other text fields through its computed data:

{
  "batt1": "OFF",
  "wh65batt": "OFF",
  "wh25batt": "OFF",
  "frostrisk": "No risk",
  "humidex_perception": "Comfortable",
  "thermalperception": "Dry"
}

This patch fixes it, by skipping all non-numeric fields when provisioning the Grafana panel.

With kind regards, Andreas.

[^2]: Did anyone of you observe this flaw in the past already, @tonkenfo, @wetterfrosch, or @ClemensGruber?

amotl commented 1 year ago

A corresponding test case for this issue is part of GH-125.

https://github.com/daq-tools/kotori/blob/139123244f18d3fdd6ed7c611679340671c501de/test/test_device_fineoffset.py#L128-L132