Fix the partial missing metrics in Create Alarm Definition flow

- The UI will call the monasca-api more than once to get all
metrics when the limit of API is exceeded.
- Added compatibility to cassandra and influxdb

Change-Id: I15c53c05517a6f8eb0fc29f3adc3667485ee6772
Story: 2004430
Task: 28091
This commit is contained in:
Martin Chacon Piza 2018-11-27 15:22:33 +01:00
parent 7b9da968b4
commit f98f325fc2
1 changed files with 18 additions and 2 deletions

View File

@ -27,9 +27,25 @@ from monitoring.alarmdefs import constants
from monitoring import api
def _get_metrics_call(request, offset=None):
return api.monitor.metrics_list(request, offset=offset)\
if offset else api.monitor.metrics_list(request)
def _get_metrics(request):
metrics = api.monitor.metrics_list(request)
return json.dumps(metrics)
metrics_aggregation = _get_metrics_call(request)
if not metrics_aggregation:
return []
# offset defined as the id of last metric.
offset = metrics_aggregation[-1]['id']
while True:
metrics_batch = _get_metrics_call(request, offset)
if not metrics_batch:
break
metrics_aggregation += metrics_batch
offset = metrics_batch[-1]['id']
return json.dumps(metrics_aggregation)
def _get_notifications(request):