python impl. of metric-name-list for InfluxDB returns incomplete results
Change-Id: I269344f59684c74f9a8ad556620f1b786906cbc5 Closes-Bug: 1628798
This commit is contained in:
@@ -34,5 +34,5 @@ class NotificationsTypeV2API(object):
|
||||
def on_put(self, req, res):
|
||||
res.status = '501 Not Implemented'
|
||||
|
||||
def on_patch(self, req):
|
||||
def on_patch(self, req, res):
|
||||
res.status = '501 Not Implemented'
|
||||
|
@@ -33,7 +33,6 @@ LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
try:
|
||||
@@ -59,6 +58,15 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
||||
|
||||
return query
|
||||
|
||||
def _build_show_measurements_query(self, dimensions, name, tenant_id, region):
|
||||
|
||||
where_clause = self._build_where_clause(dimensions, name, tenant_id,
|
||||
region)
|
||||
|
||||
query = 'show measurements ' + where_clause
|
||||
|
||||
return query
|
||||
|
||||
def _build_select_measurement_query(self, dimensions, name, tenant_id,
|
||||
region, start_timestamp, end_timestamp,
|
||||
offset, limit):
|
||||
@@ -277,7 +285,6 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
||||
dimensions,
|
||||
start_timestamp,
|
||||
end_timestamp):
|
||||
|
||||
metric = {u'id': str(metric_id),
|
||||
u'name': series[u'name'],
|
||||
u'dimensions': dimensions}
|
||||
@@ -287,17 +294,22 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
||||
|
||||
return json_metric_list
|
||||
|
||||
def _build_serie_name_list(self, series_names):
|
||||
def _build_measurement_name_list(self, measurement_names):
|
||||
"""read measurement names from InfluxDB response
|
||||
|
||||
Extract the measurement names (InfluxDB terminology) from the SHOW MEASURMENTS result to yield metric names
|
||||
:param measurement_names: result from SHOW MEASUREMENTS call (json-dict)
|
||||
:return: list of metric-names (Monasca terminology)
|
||||
"""
|
||||
|
||||
json_metric_list = []
|
||||
|
||||
if not series_names:
|
||||
if not measurement_names:
|
||||
return json_metric_list
|
||||
|
||||
if 'series' in series_names.raw:
|
||||
for series in series_names.raw['series']:
|
||||
name = {u'name': series[u'name']}
|
||||
json_metric_list.append(name)
|
||||
for name in measurement_names.raw.get(u'series', [{}])[0].get(u'values', []):
|
||||
entry = {u'name': name[0]}
|
||||
json_metric_list.append(entry)
|
||||
|
||||
json_metric_list = sorted(json_metric_list)
|
||||
return json_metric_list
|
||||
@@ -396,10 +408,12 @@ class MetricsRepository(metrics_repository.AbstractMetricsRepository):
|
||||
|
||||
try:
|
||||
|
||||
query = self._build_show_series_query(dimensions, None, tenant_id,
|
||||
region)
|
||||
query = self._build_show_measurements_query(dimensions, None, tenant_id,
|
||||
region)
|
||||
|
||||
result = self.influxdb_client.query(query)
|
||||
json_name_list = self._build_serie_name_list(result)
|
||||
|
||||
json_name_list = self._build_measurement_name_list(result)
|
||||
return json_name_list
|
||||
|
||||
except Exception as ex:
|
||||
|
Reference in New Issue
Block a user