From 40a393c3202048c856d873815b37746cffd748a9 Mon Sep 17 00:00:00 2001 From: Alex Stefanescu Date: Mon, 18 Mar 2024 19:44:54 +0100 Subject: [PATCH] Update metrics collector, remove jobs key --- aleph/metrics/collectors.py | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/aleph/metrics/collectors.py b/aleph/metrics/collectors.py index f68a186f33..6b773024a0 100644 --- a/aleph/metrics/collectors.py +++ b/aleph/metrics/collectors.py @@ -148,23 +148,22 @@ def collect(self): stages = {} for collection_status in status["datasets"].values(): - for job_status in collection_status["jobs"]: - for stage_status in job_status["stages"]: - stage = stage_status["stage"] - pending = stage_status["pending"] - running = stage_status["running"] - - if stage not in stages: - stages[stage] = { - "pending": 0, - "running": 0, - } + for stage_status in collection_status["stages"]: + stage = stage_status["stage"] + pending = stage_status["pending"] + running = stage_status["running"] + if stage not in stages: stages[stage] = { - "pending": stages[stage].get("pending") + pending, - "running": stages[stage].get("running") + running, + "pending": 0, + "running": 0, } + stages[stage] = { + "pending": stages[stage].get("pending") + pending, + "running": stages[stage].get("running") + running, + } + tasks_gauge = GaugeMetricFamily( "aleph_tasks", "Total number of pending or running tasks in a given stage",