Merge "Fix Alarm status Panel on Overview page"

This commit is contained in:
Zuul 2018-05-11 08:40:47 +00:00 committed by Gerrit Code Review
commit 181bcb1258

View File

@ -162,11 +162,15 @@ def get_monitoring_services(request):
def show_by_dimension(data, dim_name): def show_by_dimension(data, dim_name):
if 'dimensions' in data['metrics'][0]: if 'metrics' in data:
dimensions = data['metrics'][0]['dimensions'] dimensions = []
if dim_name in dimensions: for metric in data['metrics']:
return str(data['metrics'][0]['dimensions'][dim_name].encode('utf-8')) if 'dimensions' in metric:
return "" if dim_name in metric['dimensions']:
dimensions.append(str(metric['dimensions'][dim_name].encode('utf-8')))
return dimensions
return []
def get_status(alarms): def get_status(alarms):
@ -198,8 +202,9 @@ def generate_status(request):
if 'groupBy' in row: if 'groupBy' in row:
alarms_by_group = {} alarms_by_group = {}
for a in alarms: for a in alarms:
group = show_by_dimension(a, row['groupBy']) groups = show_by_dimension(a, row['groupBy'])
if group: if groups:
for group in groups:
group_alarms = alarms_by_group.setdefault(group, []) group_alarms = alarms_by_group.setdefault(group, [])
group_alarms.append(a) group_alarms.append(a)
services = [] services = []