]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
prometheus: Handle the TIME perf counter type metrics
authorBoris Ranto <branto@redhat.com>
Mon, 30 Apr 2018 23:12:02 +0000 (01:12 +0200)
committerBoris Ranto <branto@redhat.com>
Fri, 1 Jun 2018 12:26:25 +0000 (14:26 +0200)
This patch correctly sets the PERFCOUNTER_MASK to 3 so that the
PERFCOUNTER_TIME metrics are not ignored by the mgr_module code. It also
converts the TIME metrics from nanoseconds to seconds just like the ceph
perf dump does and exposes the metrics via prometheus module.

Signed-off-by: Boris Ranto <branto@redhat.com>
(cherry picked from commit 056bc08d51306f4e4d031d1e3ff68ad7312c55d8)

Conflicts:
src/pybind/mgr/mgr_module.py: trivial resolution

src/pybind/mgr/mgr_module.py
src/pybind/mgr/prometheus/module.py

index 38283d2446d34bf0ef957c1c5f1e18eab3cfb76e..933858151ff4d5b32a15749e971c61152719bf62 100644 (file)
@@ -221,7 +221,7 @@ class MgrModule(ceph_module.BaseMgrModule):
     PERFCOUNTER_LONGRUNAVG = 4
     PERFCOUNTER_COUNTER = 8
     PERFCOUNTER_HISTOGRAM = 0x10
-    PERFCOUNTER_TYPE_MASK = ~2
+    PERFCOUNTER_TYPE_MASK = ~3
 
     def __init__(self, module_name, py_modules_ptr, this_ptr):
         self.module_name = module_name
@@ -313,6 +313,13 @@ class MgrModule(ceph_module.BaseMgrModule):
         
         return ''
 
+    def _perfvalue_to_value(self, stattype, value):
+        if stattype & self.PERFCOUNTER_TIME:
+            # Convert from ns to seconds
+            return value / 1000000000.0
+        else:
+            return value
+
     def get_server(self, hostname):
         """
         Called by the plugin to load information about a particular
@@ -597,4 +604,4 @@ class MgrModule(ceph_module.BaseMgrModule):
         and/or the monitor cluster is down.
         """
 
-        return self._ceph_have_mon_connection()
\ No newline at end of file
+        return self._ceph_have_mon_connection()
index c7daa128dd8af16fee1ae408895653f2684d8d18..dea9b5971788088c0368fcda6c680fdc556c40fe 100644 (file)
@@ -554,7 +554,8 @@ class Module(MgrModule):
                         ("ceph_daemon",),
                     ))
 
-                self.metrics.append(path, counter_info['value'], (daemon,))
+                value = self._perfvalue_to_value(counter_info['type'], counter_info['value'])
+                self.metrics.append(path, value, (daemon,))
         # It is sufficient to reset the pending metrics once per scrape
         self.metrics.reset()