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:
parent
7b9da968b4
commit
f98f325fc2
@ -27,9 +27,25 @@ from monitoring.alarmdefs import constants
|
|||||||
from monitoring import api
|
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):
|
def _get_metrics(request):
|
||||||
metrics = api.monitor.metrics_list(request)
|
metrics_aggregation = _get_metrics_call(request)
|
||||||
return json.dumps(metrics)
|
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):
|
def _get_notifications(request):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user