Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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