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-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F28200%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 --- 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