]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mgr: add slash to prometheus illegal metric name characters 28485/head
authorMykola Golub <mgolub@suse.com>
Wed, 29 May 2019 06:38:35 +0000 (07:38 +0100)
committerMykola Golub <mgolub@suse.com>
Tue, 11 Jun 2019 07:27:33 +0000 (10:27 +0300)
(replace with underscore)

While here, change the sequence of replaces to a single regex, as it
becomes too long.

Signed-off-by: Mykola Golub <mgolub@suse.com>
(cherry picked from commit 425c5358fed9376939cff8a922c3ce1186d6b9e2)

src/pybind/mgr/prometheus/module.py

index d3ea3d48a1be0222290b866dc5079f2912180dce..ca2e8d907f0972e4d91897cf3a11f1054153e01f 100644 (file)
@@ -120,8 +120,7 @@ class Metric(object):
 
         def promethize(path):
             ''' replace illegal metric name characters '''
-            result = path.replace('.', '_').replace(
-                '+', '_plus').replace('::', '_').replace(' ', '_')
+            result = re.sub(r'[./\s]|::', '_', path).replace('+', '_plus')
 
             # Hyphens usually turn into underscores, unless they are
             # trailing