From 76d1918724320b7d6b1120b57b3002bb24099001 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Wed, 9 Aug 2017 17:22:49 +0200 Subject: [PATCH] pybind/mgr/prometheus: add device_class label to osd metrics Signed-off-by: Jan Fajerski --- src/pybind/mgr/prometheus/module.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 34f828fff53e1..2b8fb064d18ee 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -300,16 +300,17 @@ def get_mon_status(self): def get_osd_status(self): '''TODO add device_class label!!!''' osd_status = self.get('osd_stats')['osd_stats'] - osd_devs = self.get('osd_metadata') + osd_dev = self.get('osd_map_crush')['devices'] for osd in osd_status: id_ = osd['osd'] - dev_class = :q + dev_class = next((osd for osd in osd_dev if osd['id'] == id_)) for stat in OSD_STATS: path = 'osd_{}'.format(stat) - self.metrics[path].set(osd[stat], (id_,)) - for p_stat in OSD_PERF_STAT: - path = 'osd_{}'.format(stat) - self.metrics[path].set(osd['perf_stat'][stat], (id_,)) + self.metrics[path].set(osd[stat], (id_,dev_class['class'])) + for p_stat in OSD_PERF_STATS: + path = 'osd_{}'.format(p_stat) + self.metrics[path].set(osd['perf_stat'][p_stat], + (id_,dev_class['class'])) def get_pg_status(self): pg_s = self.get('pg_summary')['by_osd']