Browse Source

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
changes/96/706296/2
Iury Gregory Melo Ferreira 2 weeks ago
parent
commit
23a9cd9471
2 changed files with 16 additions and 6 deletions
  1. +10
    -6
      ironic_prometheus_exporter/parsers/redfish.py
  2. +6
    -0
      releasenotes/notes/fix-duplicated-timeseries-in-collectorregistry-78f6828eca3a0607.yaml

+ 10
- 6
ironic_prometheus_exporter/parsers/redfish.py View File

@@ -250,11 +250,15 @@ def category_registry(node_message, metrics_registry):

for metric, details in metrics.items():

for value, labels in details:

desc = descriptions.get_metric_description('redfish', metric)

gauge = Gauge(metric, desc, labelnames=labels,
registry=metrics_registry)
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:
gauge.labels(**labels).set(value)

+ 6
- 0
releasenotes/notes/fix-duplicated-timeseries-in-collectorregistry-78f6828eca3a0607.yaml View File

@@ -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…
Cancel
Save