]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/prometheus: export zero valued pg state metrics 49786/head
authorAvan Thakkar <athakkar@redhat.com>
Mon, 16 Jan 2023 12:41:06 +0000 (18:11 +0530)
committerAvan Thakkar <athakkar@redhat.com>
Thu, 19 Jan 2023 10:22:04 +0000 (15:52 +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.

(cherry picked from commit 17d1ecc914b2fe6c5d9e8045a999985988c39447)

src/pybind/mgr/prometheus/module.py

index 1e47e4aa1fe44dfc1aa91cdb4e39d295c85c5ca5..4913411407fffd4cefc56a4e602d3314687e0729 100644 (file)
@@ -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('+'):