Fix empty metadata exception in Prometheus collector
Metadata defined in metrics.yml may be non-existent in data['metric'] from Prometheus results. Deal with the exception similarly to the Gnocchi collector. Change-Id: I02ee50793f3c46050250ca1c4094dd4ef0736ca6 Signed-off-by: Ning Yao <yaoning@unitedstack.com> Story: 2008123 Task: 40845
This commit is contained in:
@@ -130,7 +130,7 @@ class PrometheusCollector(collector.BaseCollector):
|
||||
"""
|
||||
metadata = {}
|
||||
for meta in self.conf[metric_name]['metadata']:
|
||||
metadata[meta] = data['metric'][meta]
|
||||
metadata[meta] = data['metric'].get(meta, '')
|
||||
|
||||
groupby = {scope_key: scope_id}
|
||||
for meta in self.conf[metric_name]['groupby']:
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
---
|
||||
issues:
|
||||
- |
|
||||
Fixes exceptions in Prometheus collector when metadata defined in
|
||||
``metrics.yml`` is not present on metrics retrieved from Prometheus.
|
||||
Reference in New Issue
Block a user