From 683b47d0f1f20219558f008657f11be707fc863d Mon Sep 17 00:00:00 2001 From: Haibo Lin Date: Jun 17 2021 03:13:34 +0000 Subject: Add expected number of hosts to metrics JIRA: RHELCMP-5494 Signed-off-by: Haibo Lin --- diff --git a/server/conf/config.py b/server/conf/config.py index 7419101..af07400 100644 --- a/server/conf/config.py +++ b/server/conf/config.py @@ -157,6 +157,9 @@ class BaseConfiguration(object): # 'another_raw_config': ['arg1', ...], # } + # Expected number of celery backends + EXPECTED_BACKEND_NUMBER = 1 + class DevConfiguration(BaseConfiguration): DEBUG = True diff --git a/server/odcs/server/metrics.py b/server/odcs/server/metrics.py index d3fc49b..97ea1de 100644 --- a/server/odcs/server/metrics.py +++ b/server/odcs/server/metrics.py @@ -114,6 +114,7 @@ class WorkerCountThread(threading.Thread): """ Thread providing and updating following metrics: + - celery_workers_expected - Number of expected workers. - celery_workers_totals - Number of alive workers. - celery_workers[worker_name] - 1 if worker is online, 0 if offline. """ @@ -121,10 +122,16 @@ class WorkerCountThread(threading.Thread): def __init__(self, registry=None): super(WorkerCountThread, self).__init__() self.daemon = True + self.workers_expected = Gauge( + "celery_workers_expected", "Number of expected workers", registry=registry + ) + self.workers_expected.set(conf.expected_backend_number) + self.workers_total = Gauge( "celery_workers_totals", "Number of alive workers", registry=registry ) self.workers_total.set(0) + self.workers = Gauge( "celery_workers", "Number of alive workers",