massive flux performance increase

This commit is contained in:
mwiegand 2022-07-07 19:00:36 +02:00
parent e44fc3dc04
commit 15f0317fbe
2 changed files with 2 additions and 2 deletions

View file

@ -142,7 +142,7 @@ for dashboard_id, monitored_node in enumerate(monitored_nodes, start=1):
host=monitored_node.name,
negative=query_config.get('negative', False),
boolean_to_int=query_config.get('boolean_to_int', False),
resolution=query_config.get('resolution', 1) * 4,
resolution=query_config.get('resolution', 1),
minimum=query_config.get('minimum', None),
filters={
'host': monitored_node.name,

View file

@ -4,6 +4,7 @@ from(bucket: "${bucket}")
<% values = values if isinstance(values, list) else [values] %>\
|> filter(fn: (r) => ${' or '.join(f'r["{key}"] == "{value}"' for value in values)})
% endfor
|> aggregateWindow(every: duration(v: int(v: v.windowPeriod)*${resolution}), fn: mean, createEmpty: false) // aggregate early for best performance
% if minimum:
|> filter(fn: (r) => r._value > ${minimum})
% endif
@ -13,7 +14,6 @@ from(bucket: "${bucket}")
% if boolean_to_int:
|> map(fn: (r) => ({r with _value: if r._value == true then 1 else 0 }))
% endif
|> aggregateWindow(every: duration(v: int(v: v.windowPeriod)*${resolution}), fn: mean, createEmpty: false)
% if negative:
|> map(fn: (r) => ({r with _value: r._value * - 1.0}))
% endif