mirror of https://github.com/jumpserver/jumpserver
fix: api prometheus count
parent
e5bb28231a
commit
8bedef92f0
|
@ -97,10 +97,10 @@ class ComponentsPrometheusMetricsUtil(TypedComponentsStatusMetricsUtil):
|
||||||
def convert_status_metrics(metrics):
|
def convert_status_metrics(metrics):
|
||||||
return {
|
return {
|
||||||
'any': metrics['total'],
|
'any': metrics['total'],
|
||||||
'normal': metrics['normal'],
|
'normal': len(metrics['normal']),
|
||||||
'high': metrics['high'],
|
'high': len(metrics['high']),
|
||||||
'critical': metrics['critical'],
|
'critical': len(metrics['critical']),
|
||||||
'offline': metrics['offline']
|
'offline': len(metrics['offline'])
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_component_status_metrics(self):
|
def get_component_status_metrics(self):
|
||||||
|
@ -112,8 +112,8 @@ class ComponentsPrometheusMetricsUtil(TypedComponentsStatusMetricsUtil):
|
||||||
tp = metric['type']
|
tp = metric['type']
|
||||||
prometheus_metrics.append(f'## 组件: {tp}')
|
prometheus_metrics.append(f'## 组件: {tp}')
|
||||||
status_metrics = self.convert_status_metrics(metric)
|
status_metrics = self.convert_status_metrics(metric)
|
||||||
for status, value in status_metrics.items():
|
for status, count in status_metrics.items():
|
||||||
metric_text = status_metric_text % (tp, status, value)
|
metric_text = status_metric_text % (tp, status, count)
|
||||||
prometheus_metrics.append(metric_text)
|
prometheus_metrics.append(metric_text)
|
||||||
return prometheus_metrics
|
return prometheus_metrics
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue