summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/prometheus
diff options
context:
space:
mode:
authorBenoît Knecht <bknecht@protonmail.ch>2021-11-12 15:10:52 +0100
committerBenoît Knecht <bknecht@protonmail.ch>2022-01-11 12:48:55 +0100
commit01b42c1c51a1b4142adcde0c2c673b60e61e4697 (patch)
treefbb583f3bd0058542c5e8239e7cf8c45641ec633 /src/pybind/mgr/prometheus
parentpybind/mgr/mgr_module.py: Set instance_id label for rgw (diff)
downloadceph-01b42c1c51a1b4142adcde0c2c673b60e61e4697.tar.xz
ceph-01b42c1c51a1b4142adcde0c2c673b60e61e4697.zip
pybind/mgr/prometheus: Add instance_id metadata for rgw
In order to get the `ceph_daemon` label for `rgw` metrics corresponding to the value before #40220, we need to add the `instance_id` label to the `ceph_rgw_metadata` metric. This way, the old `ceph_daemon` label can be added to any `ceph_rgw_*` metric using the following PromQL query, for instance: ``` ceph_rgw_req * on (instance_id) group_left(ceph_daemon) ceph_rgw_metadata ``` Signed-off-by: Benoît Knecht <bknecht@protonmail.ch>
Diffstat (limited to 'src/pybind/mgr/prometheus')
-rw-r--r--src/pybind/mgr/prometheus/module.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py
index e585c8752e3..91f3528f79a 100644
--- a/src/pybind/mgr/prometheus/module.py
+++ b/src/pybind/mgr/prometheus/module.py
@@ -102,7 +102,7 @@ OSD_STATS = ['apply_latency_ms', 'commit_latency_ms']
POOL_METADATA = ('pool_id', 'name', 'type', 'description', 'compression_mode')
-RGW_METADATA = ('ceph_daemon', 'hostname', 'ceph_version')
+RGW_METADATA = ('ceph_daemon', 'hostname', 'ceph_version', 'instance_id')
RBD_MIRROR_METADATA = ('ceph_daemon', 'id', 'instance_id', 'hostname',
'ceph_version')
@@ -808,7 +808,7 @@ class Module(MgrModule):
# export standby mds metadata, default standby fs_id is '-1'
for standby in fs_map['standbys']:
id_ = standby['name']
- host, version = servers.get((id_, 'mds'), ('', ''))
+ host, version, _ = servers.get((id_, 'mds'), ('', '', ''))
addr, rank = standby['addr'], standby['rank']
self.metrics['mds_metadata'].set(1, (
'mds.{}'.format(id_), '-1',
@@ -830,7 +830,7 @@ class Module(MgrModule):
self.log.debug('mdsmap: {}'.format(fs['mdsmap']))
for gid, daemon in fs['mdsmap']['info'].items():
id_ = daemon['name']
- host, version = servers.get((id_, 'mds'), ('', ''))
+ host, version, _ = servers.get((id_, 'mds'), ('', '', ''))
self.metrics['mds_metadata'].set(1, (
'mds.{}'.format(id_), fs['id'],
host, daemon['addr'],
@@ -844,7 +844,7 @@ class Module(MgrModule):
for mon in mon_status['monmap']['mons']:
rank = mon['rank']
id_ = mon['name']
- host_version = servers.get((id_, 'mon'), ('', ''))
+ host_version = servers.get((id_, 'mon'), ('', '', ''))
self.metrics['mon_metadata'].set(1, (
'mon.{}'.format(id_), host_version[0],
mon['public_addr'].rsplit(':', 1)[0], rank,
@@ -870,7 +870,7 @@ class Module(MgrModule):
for module in mgr_map['available_modules']}
for mgr in all_mgrs:
- host, version = servers.get((mgr, 'mgr'), ('', ''))
+ host, version, _ = servers.get((mgr, 'mgr'), ('', '', ''))
if mgr == active:
_state = 1
else:
@@ -928,13 +928,13 @@ class Module(MgrModule):
'osd.{}'.format(id_),
))
- def get_service_list(self) -> Dict[Tuple[str, str], Tuple[str, str]]:
+ def get_service_list(self) -> Dict[Tuple[str, str], Tuple[str, str, str]]:
ret = {}
for server in self.list_servers():
version = cast(str, server.get('ceph_version', ''))
host = cast(str, server.get('hostname', ''))
for service in cast(List[ServiceInfoT], server.get('services', [])):
- ret.update({(service['id'], service['type']): (host, version)})
+ ret.update({(service['id'], service['type']): (host, version, service.get('name', ''))})
return ret
@profile_method()
@@ -972,7 +972,7 @@ class Module(MgrModule):
"skipping output".format(id_))
continue
- host_version = servers.get((str(id_), 'osd'), ('', ''))
+ host_version = servers.get((str(id_), 'osd'), ('', '', ''))
# collect disk occupation metadata
osd_metadata = self.get_metadata("osd", str(id_))
@@ -1086,11 +1086,11 @@ class Module(MgrModule):
for key, value in servers.items():
service_id, service_type = key
if service_type == 'rgw':
- hostname, version = value
+ hostname, version, name = value
self.metrics['rgw_metadata'].set(
1,
- ('{}.{}'.format(service_type, service_id),
- hostname, version)
+ ('{}.{}'.format(service_type, name),
+ hostname, version, service_id)
)
elif service_type == 'rbd-mirror':
mirror_metadata = self.get_metadata('rbd-mirror', service_id)