]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: pg count by pool
authorAleksei Zakharov <zakharov.a.g@yandex.ru>
Fri, 20 Dec 2019 15:05:05 +0000 (18:05 +0300)
committerAleksei Zakharov <zaharov@selectel.ru>
Wed, 29 Jan 2020 14:26:20 +0000 (17:26 +0300)
If we have all other stats by pool, it's better to have total
count by pool too. We always can sum() all of total, but it's
hard to count by-pool total.

Signed-off-by: Aleksei Zakharov <zakharov.a.g@yandex.ru>
src/pybind/mgr/prometheus/module.py

index d58c1f67a18ecff39d9c220e050f6619e7af481f..d311c3cb4312192bf3523a6f7d9470e34b001db2 100644 (file)
@@ -318,7 +318,8 @@ class Module(MgrModule):
         metrics['pg_total'] = Metric(
             'gauge',
             'pg_total',
-            'PG Total Count'
+            'PG Total Count',
+            ('pool_id',)
         )
 
         for flag in OSD_FLAGS:
@@ -511,13 +512,11 @@ class Module(MgrModule):
             self.metrics['mgr_module_can_run'].set(_can_run, (mod_name,))
 
     def get_pg_status(self):
-        # Set total count of PGs, first
-        pg_status = self.get('pg_status')
-        self.metrics['pg_total'].set(pg_status['num_pgs'])
 
         pg_summary = self.get('pg_summary')
 
         for pool in pg_summary['by_pool']:
+            total = 0
             for state_name, count in pg_summary['by_pool'][pool].items():
                 reported_states = {}
 
@@ -539,6 +538,8 @@ class Module(MgrModule):
                         except KeyError:
                             self.log.warn(
                                 "skipping pg in unknown state {}".format(state))
+                total = total + count
+            self.metrics['pg_total'].set(total,(pool,))
 
     def get_osd_stats(self):
         osd_stats = self.get('osd_stats')