From eb6dd28975c2336b832ae28de2abbf6d4f914e18 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Knecht?= Date: Thu, 28 Oct 2021 18:49:07 +0200 Subject: [PATCH] mgr/ActivePyModules: Add metadata id in dump_server() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit 2db1aaabe5f4627bb7b177ab3441593f08aa7cbe) --- src/mgr/ActivePyModules.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/mgr/ActivePyModules.cc b/src/mgr/ActivePyModules.cc index 8622c60386f..199b48beb0f 100644 --- a/src/mgr/ActivePyModules.cc +++ b/src/mgr/ActivePyModules.cc @@ -72,7 +72,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 @@ -81,10 +82,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(); -- 2.47.3