Skip to content
Snippets Groups Projects
Commit 87d20b1d authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-758: Add index column to precompute absolute element position. This helps...

L2SS-758: Add index column to precompute absolute element position. This helps in overviews that simply display a flattened array.
parent 197db4df
No related branches found
No related tags found
1 merge request!305L2SS-758: Tune prometheus archiving
...@@ -69,7 +69,7 @@ class CustomCollector(object): ...@@ -69,7 +69,7 @@ class CustomCollector(object):
self.proxy_timeout = proxy_timeout self.proxy_timeout = proxy_timeout
@staticmethod @staticmethod
def _to_metric(dev, attr_info, x, y, value): def _to_metric(dev, attr_info, x, y, idx, value):
""" Convert the given values to a (labels, value) pair, used to construct a Metric. """ """ Convert the given values to a (labels, value) pair, used to construct a Metric. """
if attr_info.data_type in [ArgType.DevShort, ArgType.DevLong, ArgType.DevUShort, ArgType.DevULong, ArgType.DevLong64, ArgType.DevULong64, ArgType.DevInt, ArgType.DevFloat, ArgType.DevDouble]: if attr_info.data_type in [ArgType.DevShort, ArgType.DevLong, ArgType.DevUShort, ArgType.DevULong, ArgType.DevLong64, ArgType.DevULong64, ArgType.DevInt, ArgType.DevFloat, ArgType.DevDouble]:
...@@ -97,12 +97,12 @@ class CustomCollector(object): ...@@ -97,12 +97,12 @@ class CustomCollector(object):
return None return None
# (labels, value) # (labels, value)
return ([dev.dev_name(), attr_info.name, str_value, data_type, f"{x:02}", f"{y:02}"], float_value) return ([dev.dev_name(), attr_info.name, str_value, data_type, f"{x:02}", f"{y:02}", f"{idx:03}"]], float_value)
def metrics_scalar(self, dev, attr_info, attr_value): def metrics_scalar(self, dev, attr_info, attr_value):
""" Return all metrics for a given SCALAR attribute. """ """ Return all metrics for a given SCALAR attribute. """
new_metric = self._to_metric(dev, attr_info, 0, 0, attr_value.value) new_metric = self._to_metric(dev, attr_info, 0, 0, 0, attr_value.value)
return [new_metric] if new_metric else [] return [new_metric] if new_metric else []
def metrics_spectrum(self, dev, attr_info, attr_value): def metrics_spectrum(self, dev, attr_info, attr_value):
...@@ -110,7 +110,7 @@ class CustomCollector(object): ...@@ -110,7 +110,7 @@ class CustomCollector(object):
metrics = [] metrics = []
for x in range(int(attr_value.dim_x)): for x in range(int(attr_value.dim_x)):
new_metric = self._to_metric(dev, attr_info, x, 0, attr_value.value[x]) new_metric = self._to_metric(dev, attr_info, x, 0, x, attr_value.value[x])
metrics.append(new_metric) if new_metric else None metrics.append(new_metric) if new_metric else None
return metrics return metrics
...@@ -124,7 +124,7 @@ class CustomCollector(object): ...@@ -124,7 +124,7 @@ class CustomCollector(object):
""" NOTE: We switch x and y in the annotation, to allow queries to combine 1D and 2D arrays in their first dimension using the same label (x). We effectively expose """ NOTE: We switch x and y in the annotation, to allow queries to combine 1D and 2D arrays in their first dimension using the same label (x). We effectively expose
the array as [x][y] instead of [y][x]. """ the array as [x][y] instead of [y][x]. """
new_metric = self._to_metric(dev, attr_info, y, x, attr_value.value[y][x]) new_metric = self._to_metric(dev, attr_info, y, x, y * attr_value.dim_x + x, attr_value.value[y][x])
metrics.append(new_metric) if new_metric else None metrics.append(new_metric) if new_metric else None
return metrics return metrics
...@@ -182,7 +182,7 @@ class CustomCollector(object): ...@@ -182,7 +182,7 @@ class CustomCollector(object):
logger.info("Start scraping") logger.info("Start scraping")
scrape_begin = time.time() scrape_begin = time.time()
attribute_metrics = GaugeMetricFamily("device_attribute", 'Device attribute value', labels=['device', 'name', 'str_value', 'type', 'x', 'y']) attribute_metrics = GaugeMetricFamily("device_attribute", 'Device attribute value', labels=['device', 'name', 'str_value', 'type', 'x', 'y', 'idx'])
scraping_metrics = GaugeMetricFamily("device_scraping", 'Device scraping duration', labels=['device']) scraping_metrics = GaugeMetricFamily("device_scraping", 'Device scraping duration', labels=['device'])
for device_name in self.policy.devices(): for device_name in self.policy.devices():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment