From 8375251d150397c0097718f6e93ed38e9e89cfbb Mon Sep 17 00:00:00 2001 From: jermudgeon Date: Sun, 27 Aug 2017 21:26:28 -0800 Subject: [PATCH] mgr/prometheus: Fix for MDS metrics MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit MDS metrics come in these forms: mds_mem_dir #Directories mds_mem_dir+ #Directories opened mds_mem_dir- #Directories closed In this case, continuing the trend of replacing all illegal characters with '_' results in… mds_mem_dir #Directories mds_mem_dir_ #Directories opened mds_mem_dir_ #Directories closed which is palpably a bad idea. Suggested replacement for '+' = '_plus' seems fine, and a perusal of all metrics indicate that only MDS metrics end in '-' or '+' at this time. Replacing '-' with '_minus' is probably less good for the general case, if anyone has a better idea… I suppose another alternative would be to change MDS metrics so they don't use 'illegal' characters, but this also seems cumbersome and would break more third parties. Fixes: http://tracker.ceph.com/issues/20899 Signed-off-by: Jeremy H Austin (cherry picked from commit d719cd04b294e90ab9d440ba7d033826c069a2de) --- src/pybind/mgr/prometheus/module.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index f98f1f7e6735e..99c68923dc012 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -76,7 +76,7 @@ class Metric(object): def promethize(path): ''' replace illegal metric name characters ''' - return path.replace('.', '_').replace('-', '_') + return path.replace('.', '_').replace('-', '_minus').replace('+', '_plus') def floatstr(value): ''' represent as Go-compatible float ''' -- 2.39.5