]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
prometheus: Expose number of degraded/misplaced/unfound objects 21793/head
authorBoris Ranto <branto@redhat.com>
Wed, 2 May 2018 21:32:35 +0000 (23:32 +0200)
committerBoris Ranto <branto@redhat.com>
Thu, 3 May 2018 14:06:31 +0000 (16:06 +0200)
These come from the pg dump by polling the pg_stas_sum.

Signed-off-by: Boris Ranto <branto@redhat.com>
src/pybind/mgr/prometheus/module.py

index 248fd038df893994a9ab48a37270704dfc3955e9..66e58d1dba8599ab10f3e0696c0964ffaf91ed2b 100644 (file)
@@ -102,6 +102,8 @@ RGW_METADATA = ('id', 'hostname', 'ceph_version')
 
 DISK_OCCUPATION = ('instance', 'device', 'ceph_daemon')
 
+NUM_OBJECTS = ['degraded', 'misplaced', 'unfound']
+
 
 class Metrics(object):
     def __init__(self):
@@ -253,6 +255,13 @@ class Metrics(object):
                 'DF pool {}'.format(state),
                 ('pool_id',)
             )
+        for state in NUM_OBJECTS:
+            path = 'num_objects_{}'.format(state)
+            metrics[path] = Metric(
+                'gauge',
+                path,
+                'Number of {} objects'.format(state),
+            )
 
         return metrics
 
@@ -539,6 +548,12 @@ class Module(MgrModule):
                 (service_id, hostname, version)
             )
 
+    def get_num_objects(self):
+        pg_sum = self.get('pg_summary')['pg_stats_sum']['stat_sum']
+        for obj in NUM_OBJECTS:
+            stat = 'num_objects_{}'.format(obj)
+            self.metrics.set(stat, pg_sum[stat])
+
     def collect(self):
         self.get_health()
         self.get_df()
@@ -547,6 +562,7 @@ class Module(MgrModule):
         self.get_quorum_status()
         self.get_metadata_and_osd_status()
         self.get_pg_status()
+        self.get_num_objects()
 
         for daemon, counters in self.get_all_perf_counters().items():
             for path, counter_info in counters.items():