diff options
author | avanthakkar <avanjohn@gmail.com> | 2023-07-30 23:09:36 +0200 |
---|---|---|
committer | avanthakkar <avanjohn@gmail.com> | 2023-08-01 14:26:47 +0200 |
commit | ca5691834cc30c4f9175bb0b4730750ed9df59cc (patch) | |
tree | 01953f21b9bf527b621d81cae09b3e46c3b0199c /src/exporter | |
parent | Merge pull request #52526 from rhcs-dashboard/volume-create (diff) | |
download | ceph-ca5691834cc30c4f9175bb0b4730750ed9df59cc.tar.xz ceph-ca5691834cc30c4f9175bb0b4730750ed9df59cc.zip |
exporter: fix instance_id labeld value for rgw in exporter
Signed-off-by: avanthakkar <avanjohn@gmail.com>
Diffstat (limited to 'src/exporter')
-rw-r--r-- | src/exporter/DaemonMetricCollector.cc | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/exporter/DaemonMetricCollector.cc b/src/exporter/DaemonMetricCollector.cc index cb95fcaa966..464ec6fdc83 100644 --- a/src/exporter/DaemonMetricCollector.cc +++ b/src/exporter/DaemonMetricCollector.cc @@ -149,6 +149,10 @@ void DaemonMetricCollector::dump_asok_metrics() { if (counters_labels.empty()) { auto labels_and_name = get_labels_and_metric_name(daemon_name, counter_name); + if (labels_and_name.first.empty()) { + dout(1) << "Unable to parse instance_id from daemon_name: " << daemon_name << dendl; + continue; + } labels = labels_and_name.first; counter_name = labels_and_name.second; } @@ -306,13 +310,19 @@ DaemonMetricCollector::get_labels_and_metric_name(std::string daemon_name, labels["instance_id"] = quote(tmp); } else if (daemon_name.find("rgw") != std::string::npos) { - // fetch intance_id for e.g. "okbvtv" from daemon_name=rgw.foo.ceph-node-00.okbvtv - size_t pos = daemon_name.find_last_of("."); - std::string instance_id = ""; - if (pos != std::string::npos) { - instance_id = daemon_name.substr(pos+1); + // fetch intance_id for e.g. "hrgsea" from daemon_name=rgw.foo.ceph-node-00.hrgsea.2.94739968030880 + std::vector<std::string> elems; + std::stringstream ss; + ss.str(daemon_name); + std::string item; + while (std::getline(ss, item, '.')) { + elems.push_back(item); + } + if (elems.size() >= 4) { + labels["instance_id"] = quote(elems[3]); + } else { + return std::make_pair(labels_t(), ""); } - labels["instance_id"] = quote(instance_id); } else { labels.insert({"ceph_daemon", quote(daemon_name)}); } |