From 0b42bb57c72c49206086b1b0108c7aa56aaff0f4 Mon Sep 17 00:00:00 2001 From: Mykola Golub Date: Wed, 29 May 2019 07:38:35 +0100 Subject: [PATCH] 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) --- src/pybind/mgr/prometheus/module.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 -- 2.47.3