From: Mykola Golub Date: Wed, 29 May 2019 06:38:35 +0000 (+0100) Subject: pybind/mgr: add slash to prometheus illegal metric name characters X-Git-Tag: v14.2.2~53^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28485%2Fhead;p=ceph.git pybind/mgr: add slash to prometheus illegal metric name characters (replace with underscore) While here, change the sequence of replaces to a single regex, as it becomes too long. Signed-off-by: Mykola Golub (cherry picked from commit 425c5358fed9376939cff8a922c3ce1186d6b9e2) --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index d3ea3d48a1be0..ca2e8d907f097 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -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