]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr/prometheus: prefix metrics with 'ceph'; replace :: with _
authorJan Fajerski <jfajerski@suse.com>
Fri, 4 Aug 2017 08:23:11 +0000 (10:23 +0200)
committerJohn Spray <john.spray@redhat.com>
Wed, 27 Sep 2017 18:17:59 +0000 (14:17 -0400)
Both follow prometheus best practices. While : is a legal metric
character, "Exposed metrics should not contain colons, these are for
users to use when aggregating."

Signed-off-by: Jan Fajerski <jfajerski@suse.com>
src/pybind/mgr/prometheus/module.py

index a6bfe248c114fe3d413c39ebd19aa35903cb994c..2fa834d25563adf294da7b06c836d9aaca18a0f1 100644 (file)
@@ -76,7 +76,7 @@ class Metric(object):
 
         def promethize(path):
             ''' replace illegal metric name characters '''
-            result = path.replace('.', '_').replace('+', '_plus') 
+            result = path.replace('.', '_').replace('+', '_plus').replace('::', '_')
 
             # Hyphens usually turn into underscores, unless they are
             # trailing
@@ -85,7 +85,7 @@ class Metric(object):
             else:
                 result = result.replace("-", "_")
 
-            return result
+            return "ceph_{0}".format(result)
 
         def floatstr(value):
             ''' represent as Go-compatible float '''