]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: rename get_unlabeled_perf_counters, no send labeled pc 53033/head
authorPere Diaz Bou <pere-altea@hotmail.com>
Tue, 18 Apr 2023 08:47:13 +0000 (10:47 +0200)
committerPere Diaz Bou <pere-altea@hotmail.com>
Thu, 17 Aug 2023 09:15:53 +0000 (11:15 +0200)
Signed-off-by: Pere Diaz Bou <pere-altea@hotmail.com>
(cherry picked from commit 4e89ce7e72095548dbbbfe470aa9ec2e8947535c)

src/mgr/MgrClient.cc
src/msg/async/Stack.h
src/pybind/mgr/dashboard/controllers/perf_counters.py
src/pybind/mgr/influx/module.py
src/pybind/mgr/mgr_module.py
src/pybind/mgr/prometheus/module.py
src/pybind/mgr/restful/api/perf.py
src/pybind/mgr/telegraf/module.py
src/pybind/mgr/telemetry/module.py

index 6253d267034335267af3530d227ffc0012968832..6250ea3b9f18ea0d0ddcae2fc4d0c3514e18e323 100644 (file)
@@ -14,6 +14,7 @@
 
 #include "MgrClient.h"
 
+#include "common/perf_counters_key.h"
 #include "mgr/MgrContext.h"
 #include "mon/MonMap.h"
 
@@ -331,6 +332,12 @@ void MgrClient::_send_report()
         const PerfCounters::perf_counter_data_any_d &ctr,
         const PerfCounters &perf_counters)
     {
+      // FIXME: We don't send labeled perf counters to the mgr currently.
+      auto labels = ceph::perf_counters::key_labels(perf_counters.get_name());
+      if (labels.begin() != labels.end()) {
+        return false;
+      }
+
       return perf_counters.get_adjusted_priority(ctr.prio) >= (int)stats_threshold;
     };
 
@@ -367,20 +374,20 @@ void MgrClient::_send_report()
       }
 
       if (session->declared.count(path) == 0) {
-       ldout(cct,20) << " declare " << path << dendl;
-       PerfCounterType type;
-       type.path = path;
-       if (data.description) {
-         type.description = data.description;
-       }
-       if (data.nick) {
-         type.nick = data.nick;
-       }
-       type.type = data.type;
-       type.priority = perf_counters.get_adjusted_priority(data.prio);
-       type.unit = data.unit;
-       report->declare_types.push_back(std::move(type));
-       session->declared.insert(path);
+        ldout(cct, 20) << " declare " << path << dendl;
+        PerfCounterType type;
+        type.path = path;
+        if (data.description) {
+          type.description = data.description;
+        }
+        if (data.nick) {
+          type.nick = data.nick;
+        }
+        type.type = data.type;
+        type.priority = perf_counters.get_adjusted_priority(data.prio);
+        type.unit = data.unit;
+        report->declare_types.push_back(std::move(type));
+        session->declared.insert(path);
       }
 
       encode(static_cast<uint64_t>(data.u64), report->packed);
index e19b6c89ce79034949ccfaf5f196e640c5d5b69f..6739968f4e2b7667e81a1124fcfa6a9c7f942e65 100644 (file)
@@ -276,7 +276,7 @@ class Worker {
 
     // Add labeled perfcounters
     std::string labels = ceph::perf_counters::key_create(
-      name_prefix, {{"id", std::to_string(id)}});
+        name_prefix, {{"id", std::to_string(id)}});
     PerfCountersBuilder plb_labeled(
         cct, labels, l_msgr_labeled_first,
         l_msgr_labeled_last);
index 0bd883366937142424fc3febaae14682a24f3256..ab0bdcb0b32b939d5fa997b3fdd5f25bd4a5059c 100644 (file)
@@ -79,4 +79,4 @@ class PerfCounters(RESTController):
     @EndpointDoc("Display Perf Counters",
                  responses={200: PERF_SCHEMA})
     def list(self):
-        return mgr.get_all_perf_counters()
+        return mgr.get_unlabeled_perf_counters()
index f88261b20b14badd070562b6ee91700fee223eb1..6818783b341a8bc7d8533dc9f6ca662ce1365b54 100644 (file)
@@ -253,7 +253,7 @@ class Module(MgrModule):
                 }
 
     def get_daemon_stats(self, now: str) -> Iterator[Dict[str, Any]]:
-        for daemon, counters in self.get_all_perf_counters().items():
+        for daemon, counters in self.get_unlabeled_perf_counters().items():
             svc_type, svc_id = daemon.split(".", 1)
             metadata = self.get_metadata(svc_type, svc_id)
             if metadata is not None:
index 2fabbae87c52ea60a926d5e248e3e23a2d89ddf0..f7d0eb0f54402851e195707691879dc4077c8aac 100644 (file)
@@ -2022,7 +2022,7 @@ class MgrModule(ceph_module.BaseMgrModule, MgrModuleLoggingMixin):
 
     @API.expose
     @profile_method()
-    def get_all_perf_counters(self, prio_limit: int = PRIO_USEFUL,
+    def get_unlabeled_perf_counters(self, prio_limit: int = PRIO_USEFUL,
                               services: Sequence[str] = ("mds", "mon", "osd",
                                                          "rbd-mirror", "rgw",
                                                          "tcmu-runner")) -> Dict[str, dict]:
index f2e97c9d183ad8f6782d99aa444501ea5751c6cb..96f08f027a9ecc81ad03fed76a4ab881250d75f3 100644 (file)
@@ -1652,7 +1652,7 @@ class Module(MgrModule, OrchestratorClientMixin):
         """
         Get the perf counters for all daemons
         """
-        for daemon, counters in self.get_all_perf_counters().items():
+        for daemon, counters in self.get_unlabeled_perf_counters().items():
             for path, counter_info in counters.items():
                 # Skip histograms, they are represented by long running avgs
                 stattype = self._stattype_to_str(counter_info['type'])
index 4224599f66995ae480cfd20855064ddd8cd05a02..c484ac55e445fd136583692d8423f4220df6cc46 100644 (file)
@@ -18,7 +18,7 @@ class Perf(RestController):
          - 'daemon' -- filter by daemon, accepts Python regexp
         """
 
-        counters = context.instance.get_all_perf_counters()
+        counters = context.instance.get_unlabeled_perf_counters()
 
         if 'daemon' in kwargs:
             _re = re.compile(kwargs['daemon'])
index f640f1d3a0fd82f5ec1768472bb36e0155bde7ce..541ddba4f0737ed544156e7b8787f146ce2f0230 100644 (file)
@@ -72,7 +72,7 @@ class Module(MgrModule):
                 }
 
     def get_daemon_stats(self) -> Iterable[Dict[str, Any]]:
-        for daemon, counters in self.get_all_perf_counters().items():
+        for daemon, counters in self.get_unlabeled_perf_counters().items():
             svc_type, svc_id = daemon.split('.', 1)
             metadata = self.get_metadata(svc_type, svc_id)
             if not metadata:
index cd431a2e1cc697e5ce4c0d5fbadd654dc2ce11f6..f729b9180cfb64538f5f036dc79b8e4fe7bbf4ce 100644 (file)
@@ -794,7 +794,7 @@ class Module(MgrModule):
         return crashlist
 
     def gather_perf_counters(self, mode: str = 'separated') -> Dict[str, dict]:
-        # Extract perf counter data with get_all_perf_counters(), a method
+        # Extract perf counter data with get_unlabeled_perf_counters(), a method
         # from mgr/mgr_module.py. This method returns a nested dictionary that
         # looks a lot like perf schema, except with some additional fields.
         #
@@ -810,7 +810,7 @@ class Module(MgrModule):
         #           "value": 88814109
         #       },
         #   },
-        all_perf_counters = self.get_all_perf_counters()
+        perf_counters = self.get_unlabeled_perf_counters()
 
         # Initialize 'result' dict
         result: Dict[str, dict] = defaultdict(lambda: defaultdict(
@@ -819,7 +819,7 @@ class Module(MgrModule):
         # 'separated' mode
         anonymized_daemon_dict = {}
 
-        for daemon, all_perf_counters_by_daemon in all_perf_counters.items():
+        for daemon, perf_counters_by_daemon in perf_counters.items():
             daemon_type = daemon[0:3] # i.e. 'mds', 'osd', 'rgw'
 
             if mode == 'separated':
@@ -836,7 +836,7 @@ class Module(MgrModule):
                 else:
                     result[daemon_type]['num_combined_daemons'] += 1
 
-            for collection in all_perf_counters_by_daemon:
+            for collection in perf_counters_by_daemon:
                 # Split the collection to avoid redundancy in final report; i.e.:
                 #   bluestore.kv_flush_lat, bluestore.kv_final_lat -->
                 #   bluestore: kv_flush_lat, kv_final_lat
@@ -856,12 +856,12 @@ class Module(MgrModule):
                 if mode == 'separated':
                     # Add value to result
                     result[daemon][col_0][col_1]['value'] = \
-                            all_perf_counters_by_daemon[collection]['value']
+                            perf_counters_by_daemon[collection]['value']
 
                     # Check that 'count' exists, as not all counters have a count field.
-                    if 'count' in all_perf_counters_by_daemon[collection]:
+                    if 'count' in perf_counters_by_daemon[collection]:
                         result[daemon][col_0][col_1]['count'] = \
-                                all_perf_counters_by_daemon[collection]['count']
+                                perf_counters_by_daemon[collection]['count']
                 elif mode == 'aggregated':
                     # Not every rgw daemon has the same schema. Specifically, each rgw daemon
                     # has a uniquely-named collection that starts off identically (i.e.
@@ -875,14 +875,14 @@ class Module(MgrModule):
                     # the files are of type 'pair' (real-integer-pair, integer-integer pair).
                     # In those cases, the value is a dictionary, and not a number.
                     #   i.e. throttle-msgr_dispatch_throttler-hbserver["wait"]
-                    if isinstance(all_perf_counters_by_daemon[collection]['value'], numbers.Number):
+                    if isinstance(perf_counters_by_daemon[collection]['value'], numbers.Number):
                         result[daemon_type][col_0][col_1]['value'] += \
-                                all_perf_counters_by_daemon[collection]['value']
+                                perf_counters_by_daemon[collection]['value']
 
                     # Check that 'count' exists, as not all counters have a count field.
-                    if 'count' in all_perf_counters_by_daemon[collection]:
+                    if 'count' in perf_counters_by_daemon[collection]:
                         result[daemon_type][col_0][col_1]['count'] += \
-                                all_perf_counters_by_daemon[collection]['count']
+                                perf_counters_by_daemon[collection]['count']
                 else:
                     self.log.error('Incorrect mode specified in gather_perf_counters: {}'.format(mode))
                     return {}