From 8586514ab0c433f078ff2651c6b6bb7f9068445b Mon Sep 17 00:00:00 2001 From: Avan Thakkar Date: Mon, 16 Jan 2023 18:11:06 +0530 Subject: [PATCH] mgr/prometheus: export zero valued pg state metrics Fixes: https://tracker.ceph.com/issues/58471 Signed-off-by: Avan Thakkar As per the Prometheus documentation, omitting zero metrics is not a best practice. The metric value for all PG_STATES should be initialized to zero. (cherry picked from commit 17d1ecc914b2fe6c5d9e8045a999985988c39447) --- src/pybind/mgr/prometheus/module.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pybind/mgr/prometheus/module.py b/src/pybind/mgr/prometheus/module.py index 1e47e4aa1fe44..4913411407fff 100644 --- a/src/pybind/mgr/prometheus/module.py +++ b/src/pybind/mgr/prometheus/module.py @@ -1033,6 +1033,8 @@ class Module(MgrModule): for pool in pg_summary['by_pool']: num_by_state: DefaultDict[str, int] = defaultdict(int) + for state in PG_STATES: + num_by_state[state] = 0 for state_name, count in pg_summary['by_pool'][pool].items(): for state in state_name.split('+'): -- 2.39.5