Fix timeseries in redfish parser
While trying to enable the redfish job in the CI we found: `Duplicated timeseries in CollectorRegistry: {'baremetal_fan_status'}`, this is due to the fact that we were creating multiple `Gauge` for the metric and Prometheus does not support this. We should pre-create the Gauge and update with the different sets of labels and values that were collected. Change-Id: I4f4ea8e580ccb439afa7c8e14fabb94c2d124b17
This commit is contained in:
parent
077aa058bc
commit
23a9cd9471
|
@ -250,11 +250,15 @@ def category_registry(node_message, metrics_registry):
|
||||||
|
|
||||||
for metric, details in metrics.items():
|
for metric, details in metrics.items():
|
||||||
|
|
||||||
|
LOG.debug('Creating metric %s', metric)
|
||||||
|
LOG.debug('Details of the metric: %s', details)
|
||||||
|
# details is a list of tuples that contains 2 elements (value, labels)
|
||||||
|
# let's get the first tuple and the dict of labels to extract the
|
||||||
|
# list of labels necessary for the Gauge
|
||||||
|
metric_labels = details[0][1]
|
||||||
|
desc = descriptions.get_metric_description('redfish', metric)
|
||||||
|
gauge = Gauge(metric, desc, labelnames=list(metric_labels),
|
||||||
|
registry=metrics_registry)
|
||||||
|
|
||||||
for value, labels in details:
|
for value, labels in details:
|
||||||
|
|
||||||
desc = descriptions.get_metric_description('redfish', metric)
|
|
||||||
|
|
||||||
gauge = Gauge(metric, desc, labelnames=labels,
|
|
||||||
registry=metrics_registry)
|
|
||||||
|
|
||||||
gauge.labels(**labels).set(value)
|
gauge.labels(**labels).set(value)
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
Fixes the bug in the redfish parser that would raise
|
||||||
|
`Duplicated timeseries in CollectorRegistry: {'metric_name'}` when a
|
||||||
|
metric have more that one value and different values for the labels.
|
Loading…
Reference in New Issue