Skip to content

Commit cdc5c35

Browse files
authored
Merge pull request ceph#64835 from cloudbehl/rbd-metadata
prometheus: Add RBD image metadata to prometheus Reviewed-by: Aashish Sharma <[email protected]>
2 parents 72be0e0 + 45db5f3 commit cdc5c35

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
@@ -105,6 +105,8 @@ def health_status_to_number(status: str) -> int:
105105
RBD_MIRROR_METADATA = ('ceph_daemon', 'id', 'instance_id', 'hostname',
106106
'ceph_version')
107107

108+
RBD_IMAGE_METADATA = ('pool_id', 'image_name')
109+
108110
DISK_OCCUPATION = ('ceph_daemon', 'device', 'db_device',
109111
'wal_device', 'instance', 'devices', 'device_ids')
110112

@@ -760,6 +762,13 @@ def _setup_static_metrics(self) -> Dict[str, Metric]:
760762
RBD_MIRROR_METADATA
761763
)
762764

765+
metrics['rbd_image_metadata'] = Metric(
766+
'untyped',
767+
'rbd_image_metadata',
768+
'RBD Image Metadata',
769+
RBD_IMAGE_METADATA
770+
)
771+
763772
metrics['pg_total'] = Metric(
764773
'gauge',
765774
'pg_total',
@@ -1360,6 +1369,20 @@ def _get_pool_info(pool: Dict[str, Any]) -> Tuple[str, str]:
13601369
self.metrics['rbd_mirror_metadata'].set(
13611370
1, rbd_mirror_metadata
13621371
)
1372+
try:
1373+
rbd = RBD()
1374+
for pool in osd_map['pools']:
1375+
pool_id = pool['pool']
1376+
pool_name = pool['pool_name']
1377+
if 'rbd' in pool.get('application_metadata', {}):
1378+
with self.rados.open_ioctx(pool_name) as ioctx:
1379+
for image_meta in rbd.list2(ioctx):
1380+
image_name = image_meta['name']
1381+
self.metrics['rbd_image_metadata'].set(
1382+
1, (str(pool_id), image_name)
1383+
)
1384+
except Exception as e:
1385+
self.log.error(f"Failed to collect RBD image metadata: {e}")
13631386

13641387
@profile_method()
13651388
def get_num_objects(self) -> None:

0 commit comments

Comments
 (0)