From b279ae25d95f6c4b8290042fc9f33c4a6f7afac2 Mon Sep 17 00:00:00 2001 From: Jan Fajerski Date: Thu, 10 Aug 2017 18:19:42 +0200 Subject: [PATCH] pybind/mgr/prometheus: export selected perf_counters Signed-off-by: Jan Fajerski (cherry picked from commit f6e2e36ba72caf6347f3bb6a985925d0e35077a2) --- src/pybind/mgr/prometheus/module.py | 38 ++++++++++++----------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 2417bc4a2df9e..a54fb0bb6c2c6 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -83,6 +83,13 @@ OSD_METADATA = ('id', 'device_class') POOL_METADATA= ('pool_id', 'name') +PERF_COUNTERS = { + 'osd': [ + 'osd.stat_bytes', + 'osd.stat_bytes_used', + ] +} + class Metric(object): def __init__(self, mtype, name, desc, labels=None): @@ -256,19 +263,19 @@ class Module(MgrModule): self.log.debug('ignoring %s, type %s' % (path, stattype)) return + daemon_type, daemon_id = daemon.split('.') + if path not in self.metrics: self.metrics[path] = Metric( stattype, path, perfcounter['description'], - ('daemon',), + (daemon_type,), ) - daemon_type, daemon_id = daemon.split('.') - self.metrics[path].set( self.get_latest(daemon_type, daemon_id, path), - (daemon,) + (daemon_id,) ) def get_health(self): @@ -293,21 +300,6 @@ class Module(MgrModule): mon_status = json.loads(self.get('mon_status')['json']) self.metrics['mon_quorum_count'].set(len(mon_status['quorum'])) - def get_osd_status(self): - '''TODO add device_class label!!!''' - osd_status = self.get('osd_stats')['osd_stats'] - osd_dev = self.get('osd_map_crush')['devices'] - for osd in osd_status: - id_ = osd['osd'] - 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_,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): # TODO add per pool status? pg_s = self.get('pg_summary')['by_osd'] @@ -343,9 +335,11 @@ class Module(MgrModule): self.get_quorum_status() self.get_metadata() self.get_pg_status() - # for daemon in self.schema.keys(): - # for path in self.schema[daemon].keys(): - # self.get_stat(daemon, path) + for daemon in self.schema.keys(): + d_type = daemon.split('.')[0] + if d_type in PERF_COUNTERS: + for path in PERF_COUNTERS[d_type]: + self.get_stat(daemon, path) return self.metrics def notify(self, ntype, nid): -- 2.39.5