From 41c8cb6307ea69b53a9aa3e2fbc10036f8cd2382 Mon Sep 17 00:00:00 2001 From: Bai Date: Fri, 20 Dec 2024 10:55:32 +0800 Subject: [PATCH] fix: api prometheus count --- apps/terminal/utils/components.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/terminal/utils/components.py b/apps/terminal/utils/components.py index 692fe28fd..da853f0c1 100644 --- a/apps/terminal/utils/components.py +++ b/apps/terminal/utils/components.py @@ -97,10 +97,10 @@ class ComponentsPrometheusMetricsUtil(TypedComponentsStatusMetricsUtil): def convert_status_metrics(metrics): return { 'any': metrics['total'], - 'normal': metrics['normal'], - 'high': metrics['high'], - 'critical': metrics['critical'], - 'offline': metrics['offline'] + 'normal': len(metrics['normal']), + 'high': len(metrics['high']), + 'critical': len(metrics['critical']), + 'offline': len(metrics['offline']) } def get_component_status_metrics(self): @@ -112,8 +112,8 @@ class ComponentsPrometheusMetricsUtil(TypedComponentsStatusMetricsUtil): tp = metric['type'] prometheus_metrics.append(f'## 组件: {tp}') status_metrics = self.convert_status_metrics(metric) - for status, value in status_metrics.items(): - metric_text = status_metric_text % (tp, status, value) + for status, count in status_metrics.items(): + metric_text = status_metric_text % (tp, status, count) prometheus_metrics.append(metric_text) return prometheus_metrics