From: John Spray Date: Mon, 28 Aug 2017 18:55:06 +0000 (+0100) Subject: mgr/prometheus: only turn - into _minus at end X-Git-Tag: v12.2.2~177^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F17868%2Fhead;p=ceph.git mgr/prometheus: only turn - into _minus at end ...of perf counter name. So that mds_mem_dir- becomes mds_mem_dir_minus, but throttle-filestore_bytes becomes throttle_filestore_bytes. At some point once this is all settled we should probably just change Ceph's internal perf counter naming to satisfy the major TSDB naming rules. Signed-off-by: John Spray (cherry picked from commit 29ac9270d43a225bb2336adaaf813c12e12a715a) --- diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 99c68923dc01..a6bfe248c114 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -76,7 +76,16 @@ class Metric(object): def promethize(path): ''' replace illegal metric name characters ''' - return path.replace('.', '_').replace('-', '_minus').replace('+', '_plus') + result = path.replace('.', '_').replace('+', '_plus') + + # Hyphens usually turn into underscores, unless they are + # trailing + if result.endswith("-"): + result = result[0:-1] + "_minus" + else: + result = result.replace("-", "_") + + return result def floatstr(value): ''' represent as Go-compatible float '''