From 425c5358fed9376939cff8a922c3ce1186d6b9e2 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 --- 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 0e4bb0cdbaed..bbbeb8332a04 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -121,8 +121,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