From fa580a6c2b07be209e6295efc4c90445045e4a15 Mon Sep 17 00:00:00 2001 From: Andreas Motl Date: Thu, 2 Mar 2023 01:11:16 +0100 Subject: [PATCH] Grafana: Only permit numeric fields to be established on Graph panels Other types will make the panel croak like `InfluxDB Error: unsupported mean iterator type: *query.stringInterruptIterator` or `InfluxDB Error: not executed`. --- CHANGES.rst | 4 ++++ kotori/daq/graphing/grafana/dashboard.py | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 340b0248..ca31c894 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -7,6 +7,10 @@ in progress =========== - CI: Update to Grafana 9.3.0 +- Grafana: Only permit numeric fields to be established on Graph panels. + Other types will make the panel croak like ``InfluxDB Error: unsupported + mean iterator type: *query.stringInterruptIterator`` or ``InfluxDB Error: + not executed``. .. _kotori-0.27.0: diff --git a/kotori/daq/graphing/grafana/dashboard.py b/kotori/daq/graphing/grafana/dashboard.py index 5edcb0ec..1df9702b 100644 --- a/kotori/daq/graphing/grafana/dashboard.py +++ b/kotori/daq/graphing/grafana/dashboard.py @@ -57,7 +57,7 @@ def make(self, data=None): # Generate panels panels_new = self.panel_generator(data=data) - #print 'panels_new:'; pprint(panels_new) + # from pprint import pprint; print("panels_new:"); pprint(panels_new) # Create whole dashboard with all panels if not dashboard.dashboard_data: @@ -268,8 +268,14 @@ def collect_fields(data, prefixes=None, sorted=True): Field name collection helper. Does a prefix search over all fields in "data" and builds a list of field names like temp1, temp2, etc. in sorted order. + + Only uses numeric fields and skips all others, because Grafana does not like them. """ + def use_field(field_name: str): + value = data.get(field_name) + return isinstance(value, (float, int)) + # Filter blacklist fields # _hex_ is from intercom.c # time is from intercom.mqtt @@ -280,12 +286,12 @@ def collect_fields(data, prefixes=None, sorted=True): if field in blacklist: continue - if prefixes is None: + if prefixes is None and use_field(field): fields.append(field) elif isinstance(prefixes, list): for prefix in prefixes: - if field.startswith(prefix) or field.endswith(prefix): + if (field.startswith(prefix) or field.endswith(prefix)) and use_field(field): fields.append(field) break