Skip to content

Commit

Permalink
Grafana: Only permit numeric fields to be established on Graph panels
Browse files Browse the repository at this point in the history
Other types will make the panel croak like `InfluxDB Error: unsupported
mean iterator type: *query.stringInterruptIterator` or `InfluxDB Error:
not executed`.
  • Loading branch information
amotl committed Mar 2, 2023
1 parent de224af commit fa580a6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
12 changes: 9 additions & 3 deletions kotori/daq/graphing/grafana/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit fa580a6

Please sign in to comment.