]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: only turn - into _minus at end 17868/head
authorJohn Spray <john.spray@redhat.com>
Mon, 28 Aug 2017 18:55:06 +0000 (19:55 +0100)
committerNathan Cutler <ncutler@suse.com>
Thu, 21 Sep 2017 04:12:57 +0000 (06:12 +0200)
...of perf counter name.

So that mds_mem_dir- becomes mds_mem_dir_minus, but
throttle-filestore_bytes becomes throttle_filestore_bytes.

At some point once this is all settled we should
probably just change Ceph's internal perf counter
naming to satisfy the major TSDB naming rules.

Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 29ac9270d43a225bb2336adaaf813c12e12a715a)

src/pybind/mgr/prometheus/module.py

index 99c68923dc0129c818620d387f27a59f81a4faeb..a6bfe248c114fe3d413c39ebd19aa35903cb994c 100644 (file)
@@ -76,7 +76,16 @@ class Metric(object):
 
         def promethize(path):
             ''' replace illegal metric name characters '''
-            return path.replace('.', '_').replace('-', '_minus').replace('+', '_plus') 
+            result = path.replace('.', '_').replace('+', '_plus') 
+
+            # Hyphens usually turn into underscores, unless they are
+            # trailing
+            if result.endswith("-"):
+                result = result[0:-1] + "_minus"
+            else:
+                result = result.replace("-", "_")
+
+            return result
 
         def floatstr(value):
             ''' represent as Go-compatible float '''