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: v15.1.0~2579^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=425c5358fed9376939cff8a922c3ce1186d6b9e2;p=ceph-ci.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 --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 0e4bb0cdbae..bbbeb8332a0 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