Skip to content

Commit c01d031

Browse files
committed
[grafana] Document the dashboard refresh interval taming mechanism
1 parent ac041e9 commit c01d031

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

kotori/daq/graphing/grafana.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,41 @@ def demo(self):
196196
def get_dashboards(self):
197197
return self.grafana_client.search(type='dash-db')
198198

199-
def tame_refresh_interval(self, interval):
199+
def tame_refresh_interval(self, preset='standard'):
200+
"""
201+
Tame refresh interval for all dashboards.
202+
203+
:param mode: Which taming preset to use. Currently, only "standard" is
204+
implemented, which is also the default preset.
205+
206+
Introduction
207+
------------
208+
The default dashboard refresh interval of 5 seconds is important
209+
for instant-on workbench operations. However, the update interval
210+
is usually just about 5 minutes after the sensor node is in the field.
211+
212+
Problem
213+
-------
214+
Having high refresh rates on many dashboards can increase the overall
215+
system usage significantly, depending on how many users are displaying
216+
them in their browsers and the complexity of the database queries
217+
issued when rendering the dashboard.
218+
219+
Solution
220+
--------
221+
In order to reduce the overall load on the data acquisition system,
222+
the refresh interval of dashboards not updated since a configurable
223+
threshold time is decreased according to rules of built-in presets.
224+
225+
The default "standard" preset currently implements the following rules:
226+
227+
- Leave all dashboards completely untouched which have been updated during the last 14 days
228+
- Apply a refresh interval of 5 minutes for all dashboards having the "live" tag
229+
- Completely disable refreshing for all dashboards having the "historical" tag
230+
- Apply a refresh interval of 30 minutes for all other dashboards
231+
232+
"""
233+
log.info('Taming dashboard refresh interval with preset="{preset}"', preset=preset)
200234
for dashboard_meta in self.get_dashboards():
201235

202236
# Get dashboard by uid
@@ -209,7 +243,7 @@ def tame_refresh_interval(self, interval):
209243
# TODO: Look at list of tags and apply interval=5m if it contains "live".
210244

211245
# Update refresh interval
212-
dashboard['dashboard']['refresh'] = interval
246+
dashboard['dashboard']['refresh'] = '5m'
213247
response = self.grafana_client.dashboards.db.create(**dashboard)
214248

215249

@@ -737,4 +771,4 @@ def collect_fields(data, prefixes=None, sorted=True):
737771
])
738772
grafana.create_dashboard(dashboard)
739773

740-
grafana.tame_refresh_interval('5m')
774+
grafana.tame_refresh_interval()

0 commit comments

Comments
 (0)