Skip to content

Commit 45db5f3

Browse files
committed
prometheus: Add RBD image metadata to prometheus
Fixes: https://tracker.ceph.com/issues/72421 Signed-off-by: Ankush Behl <[email protected]>
1 parent 149c9d1 commit 45db5f3

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/pybind/mgr/prometheus/module.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ def health_status_to_number(status: str) -> int:
100100
RBD_MIRROR_METADATA = ('ceph_daemon', 'id', 'instance_id', 'hostname',
101101
'ceph_version')
102102

103+
RBD_IMAGE_METADATA = ('pool_id', 'image_name')
104+
103105
DISK_OCCUPATION = ('ceph_daemon', 'device', 'db_device',
104106
'wal_device', 'instance', 'devices', 'device_ids')
105107

@@ -743,6 +745,13 @@ def _setup_static_metrics(self) -> Dict[str, Metric]:
743745
RBD_MIRROR_METADATA
744746
)
745747

748+
metrics['rbd_image_metadata'] = Metric(
749+
'untyped',
750+
'rbd_image_metadata',
751+
'RBD Image Metadata',
752+
RBD_IMAGE_METADATA
753+
)
754+
746755
metrics['pg_total'] = Metric(
747756
'gauge',
748757
'pg_total',
@@ -1335,6 +1344,20 @@ def _get_pool_info(pool: Dict[str, Any]) -> Tuple[str, str]:
13351344
self.metrics['rbd_mirror_metadata'].set(
13361345
1, rbd_mirror_metadata
13371346
)
1347+
try:
1348+
rbd = RBD()
1349+
for pool in osd_map['pools']:
1350+
pool_id = pool['pool']
1351+
pool_name = pool['pool_name']
1352+
if 'rbd' in pool.get('application_metadata', {}):
1353+
with self.rados.open_ioctx(pool_name) as ioctx:
1354+
for image_meta in rbd.list2(ioctx):
1355+
image_name = image_meta['name']
1356+
self.metrics['rbd_image_metadata'].set(
1357+
1, (str(pool_id), image_name)
1358+
)
1359+
except Exception as e:
1360+
self.log.error(f"Failed to collect RBD image metadata: {e}")
13381361

13391362
@profile_method()
13401363
def get_num_objects(self) -> None:

0 commit comments

Comments
 (0)