From 4a12e25d3cd0b1ec797cb6a58ba4113f3ae6608c Mon Sep 17 00:00:00 2001 From: Aashish Sharma Date: Fri, 25 Nov 2022 11:37:54 +0530 Subject: [PATCH] mgr/dashboard: Add metric relative to osd blocklist 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 (cherry picked from commit 7c910eb0411bd1681ad76ca728390f8e2b168032) --- src/pybind/mgr/prometheus/module.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 385e39d276a34..9afb24f7acbfe 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -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() -- 2.39.5