From ddca5dbe04a2647218fabff6098691edd6b7a157 Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 28 Aug 2017 19:55:06 +0100 Subject: [PATCH] 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) --- src/pybind/mgr/prometheus/module.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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 ''' -- 2.47.3