]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: export zero valued pg state metrics 49759/head
authorAvan Thakkar <athakkar@redhat.com>
Mon, 16 Jan 2023 12:41:06 +0000 (18:11 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Mon, 16 Jan 2023 17:05:04 +0000 (22:35 +0530)
Fixes: https://tracker.ceph.com/issues/58471
Signed-off-by: Avan Thakkar <athakkar@redhat.com>
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.

src/pybind/mgr/prometheus/module.py

index ab083d87d1083311105b6fa03dd74f12b44e1eda..069330c392c7d01af89cb230ad2e53bbde14df97 100644 (file)
@@ -1065,6 +1065,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('+'):