From: Benoît Knecht Date: Thu, 28 Oct 2021 16:49:07 +0000 (+0200) Subject: mgr/ActivePyModules: Add metadata id in dump_server() X-Git-Tag: v18.0.0~1460^2~4 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2db1aaabe5f4627bb7b177ab3441593f08aa7cbe;p=ceph-ci.git mgr/ActivePyModules: Add metadata id in dump_server() The `DaemonStateCollection` used to always contain the daemon name in its `DaemonKey`, but since #40220 (or more specifically afc33758e076761b8d4ec004c8f9c49b80a48770), the RadosGW registers with its instance ID instead (`rados.get_instance_id()`). As a result, the `ceph_rgw_*` metrics returned by `ceph-mgr` through the `prometheus` module have their `ceph_daemon` label include that ID instead of the daemon name, e.g. ``` ceph_rgw_req{ceph_daemon="rgw.127202"} ``` instead of ``` ceph_rgw_req{ceph_daemon="rgw.my-hostname.rgw0"} ``` This commit adds the daemon name from `state->metadata["id"]` if available, as `service.name` in the JSON document returned by `dump_server()`. Signed-off-by: Benoît Knecht --- diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 808daaf7f77..036348dc18d 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -76,7 +76,8 @@ void ActivePyModules::dump_server(const std::string &hostname, std::string ceph_version; for (const auto &[key, state] : dmc) { - without_gil([&ceph_version, state=state] { + std::string id; + without_gil([&ceph_version, &id, state=state] { std::lock_guard l(state->lock); // TODO: pick the highest version, and make sure that // somewhere else (during health reporting?) we are @@ -85,10 +86,16 @@ void ActivePyModules::dump_server(const std::string &hostname, if (ver_iter != state->metadata.end()) { ceph_version = state->metadata.at("ceph_version"); } + if (state->metadata.find("id") != state->metadata.end()) { + id = state->metadata.at("id"); + } }); f->open_object_section("service"); f->dump_string("type", key.type); f->dump_string("id", key.name); + if (!id.empty()) { + f->dump_string("name", id); + } f->close_section(); } f->close_section();