fix: 组件监控添加offline数量

pull/5270/head
Bai 2020-12-15 15:46:02 +08:00 committed by Jiangjie.Bai
parent 8e12eebceb
commit 58b6293b76
1 changed files with 6 additions and 3 deletions

View File

@ -116,7 +116,8 @@ class ComponentsMetricsUtil(object):
def get_metrics(self, tp=None): def get_metrics(self, tp=None):
components = self.get_components(tp) components = self.get_components(tp)
total_count = normal_count = high_count = critical_count = session_active_total = 0 total_count = normal_count = high_count = critical_count = offline_count = \
session_active_total = 0
for component in components: for component in components:
total_count += 1 total_count += 1
if component.is_alive: if component.is_alive:
@ -129,12 +130,13 @@ class ComponentsMetricsUtil(object):
critical_count += 1 critical_count += 1
session_active_total += component.state.get('session_active_count', 0) session_active_total += component.state.get('session_active_count', 0)
else: else:
critical_count += 1 offline_count += 1
return { return {
'total': total_count, 'total': total_count,
'normal': normal_count, 'normal': normal_count,
'high': high_count, 'high': high_count,
'critical': critical_count, 'critical': critical_count,
'offline': offline_count,
'session_active': session_active_total 'session_active': session_active_total
} }
@ -147,7 +149,8 @@ class ComponentsPrometheusMetricsUtil(ComponentsMetricsUtil):
'any': metrics['total'], 'any': metrics['total'],
'normal': metrics['normal'], 'normal': metrics['normal'],
'high': metrics['high'], 'high': metrics['high'],
'critical': metrics['critical'] 'critical': metrics['critical'],
'offline': metrics['offline']
} }
def get_prometheus_metrics_text(self): def get_prometheus_metrics_text(self):