]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add metric relative to osd blocklist 49501/head
authorAashish Sharma <aasharma@redhat.com>
Fri, 25 Nov 2022 06:07:54 +0000 (11:37 +0530)
committerAashish Sharma <aasharma@redhat.com>
Mon, 19 Dec 2022 14:55:41 +0000 (20:25 +0530)
It would be good to have a metric with number of clients "blocklisted" of command: "ceph osd blocklist ls". The reason to have this is metric is have an alert when this number raise up.

Fixes: https://tracker.ceph.com/issues/58083
Signed-off-by: Aashish Sharma <aasharma@redhat.com>
(cherry picked from commit 7c910eb0411bd1681ad76ca728390f8e2b168032)

src/pybind/mgr/prometheus/module.py

index 385e39d276a340f458e528488f08c904d3804136..9afb24f7acbfe44040cead1a293d3a233fd5ec4d 100644 (file)
@@ -69,6 +69,8 @@ def health_status_to_number(status: str) -> int:
 
 DF_CLUSTER = ['total_bytes', 'total_used_bytes', 'total_used_raw_bytes']
 
+OSD_BLOCKLIST = ['osd_blocklist_count']
+
 DF_POOL = ['max_avail', 'avail_raw', 'stored', 'stored_raw', 'objects', 'dirty',
            'quota_bytes', 'quota_objects', 'rd', 'rd_bytes', 'wr', 'wr_bytes',
            'compress_bytes_used', 'compress_under_bytes', 'bytes_used', 'percent_used']
@@ -809,6 +811,13 @@ class Module(MgrModule):
                 'DF pool {}'.format(state),
                 ('pool_id',)
             )
+        for state in OSD_BLOCKLIST:
+            path = 'cluster_{}'.format(state)
+            metrics[path] = Metric(
+                'gauge',
+                path,
+                'OSD Blocklist Count {}'.format(state),
+            )
         for state in NUM_OBJECTS:
             path = 'num_objects_{}'.format(state)
             metrics[path] = Metric(
@@ -939,6 +948,17 @@ class Module(MgrModule):
                     (pool['id'],)
                 )
 
+    @profile_method()
+    def get_osd_blocklisted_entries(self) -> None:
+        r = self.mon_command({
+            'prefix': 'osd blocklist ls',
+            'format': 'json'
+        })
+        blocklist_entries = r[2].split(' ')
+        blocklist_count = blocklist_entries[1]
+        for stat in OSD_BLOCKLIST:
+            self.metrics['cluster_{}'.format(stat)].set(int(blocklist_count))
+
     @profile_method()
     def get_fs(self) -> None:
         fs_map = self.get('fs_map')
@@ -1585,6 +1605,7 @@ class Module(MgrModule):
 
         self.get_health()
         self.get_df()
+        self.get_osd_blocklisted_entries()
         self.get_pool_stats()
         self.get_fs()
         self.get_osd_stats()