support resample option
Change-Id: If4af794048650bac5abd2ed023320f00c40092ca Depends-On: Ibda001e13ef03a1cd550eed8b662944bb51e9d98
This commit is contained in:
parent
f5035d18fb
commit
eb754ee5aa
|
@ -130,6 +130,19 @@ class MetricClientTest(base.ClientTestBase):
|
|||
'timestamp': '2015-03-06T14:34:12+00:00',
|
||||
'value': '12.0'}], measures)
|
||||
|
||||
# MEASURES GET RESAMPLE
|
||||
result = self.retry_gnocchi(
|
||||
5, 'measures', params=("show %s "
|
||||
"--aggregation mean "
|
||||
"--granularity 1 --resample 3600 "
|
||||
"--start 2015-03-06T14:32:00 "
|
||||
"--stop 2015-03-06T14:36:00"
|
||||
) % metric["id"])
|
||||
measures = self.parser.listing(result)
|
||||
self.assertEqual([{'granularity': '3600.0',
|
||||
'timestamp': '2015-03-06T14:00:00+00:00',
|
||||
'value': '27.555'}], measures)
|
||||
|
||||
# MEASURES AGGREGATION
|
||||
result = self.gnocchi(
|
||||
'measures', params=("aggregation "
|
||||
|
@ -279,6 +292,21 @@ class MetricClientTest(base.ClientTestBase):
|
|||
'timestamp': '2015-03-06T14:34:12+00:00',
|
||||
'value': '12.0'}], measures)
|
||||
|
||||
# MEASURES AGGREGATION RESAMPLE
|
||||
result = self.gnocchi(
|
||||
'measures', params=("aggregation "
|
||||
"--query \"id='metric-res'\" "
|
||||
"--resource-type \"generic\" "
|
||||
"-m metric-name --granularity 1 "
|
||||
"--aggregation mean --resample=3600 "
|
||||
"--needed-overlap 0 "
|
||||
"--start 2015-03-06T14:32:00 "
|
||||
"--stop 2015-03-06T14:36:00"))
|
||||
measures = self.parser.listing(result)
|
||||
self.assertEqual([{'granularity': '3600.0',
|
||||
'timestamp': '2015-03-06T14:00:00+00:00',
|
||||
'value': '27.555'}], measures)
|
||||
|
||||
# MEASURES AGGREGATION GROUPBY
|
||||
result = self.gnocchi(
|
||||
'measures', params=("aggregation "
|
||||
|
|
|
@ -167,7 +167,7 @@ class MetricManager(base.Manager):
|
|||
|
||||
def get_measures(self, metric, start=None, stop=None, aggregation=None,
|
||||
granularity=None, resource_id=None, refresh=False,
|
||||
**kwargs):
|
||||
resample=None, **kwargs):
|
||||
"""Get measurements of a metric
|
||||
|
||||
:param metric: ID or Name of the metric
|
||||
|
@ -184,7 +184,9 @@ class MetricManager(base.Manager):
|
|||
to get a metric by name)
|
||||
:type resource_id: str
|
||||
:param refresh: force aggregation of all known measures
|
||||
:type refres: bool
|
||||
:type refresh: bool
|
||||
:param resample: resample measures to new granularity
|
||||
:type resample: float
|
||||
|
||||
All other arguments are arguments are dedicated to custom aggregation
|
||||
method passed as-is to the Gnocchi.
|
||||
|
@ -196,7 +198,8 @@ class MetricManager(base.Manager):
|
|||
stop = stop.isoformat()
|
||||
|
||||
params = dict(start=start, stop=stop, aggregation=aggregation,
|
||||
granularity=granularity, refresh=refresh)
|
||||
granularity=granularity, refresh=refresh,
|
||||
resample=resample)
|
||||
params.update(kwargs)
|
||||
if resource_id is None:
|
||||
self._ensure_metric_is_uuid(metric)
|
||||
|
@ -210,7 +213,7 @@ class MetricManager(base.Manager):
|
|||
start=None, stop=None, aggregation=None,
|
||||
reaggregation=None, granularity=None,
|
||||
needed_overlap=None, resource_type="generic",
|
||||
groupby=None, refresh=False):
|
||||
groupby=None, refresh=False, resample=None):
|
||||
"""Get measurements of an aggregated metrics
|
||||
|
||||
:param metrics: IDs of metric or metric name
|
||||
|
@ -233,6 +236,10 @@ class MetricManager(base.Manager):
|
|||
:type resource_type: str
|
||||
:param groupby: list of attribute to group by
|
||||
:type groupby: list
|
||||
:param refresh: force aggregation of all known measures
|
||||
:type refresh: bool
|
||||
:param resample: resample measures to new granularity
|
||||
:type resample: float
|
||||
|
||||
See Gnocchi REST API documentation for the format
|
||||
of *query dictionary*
|
||||
|
@ -247,7 +254,7 @@ class MetricManager(base.Manager):
|
|||
params = dict(start=start, stop=stop, aggregation=aggregation,
|
||||
reaggregation=reaggregation, granularity=granularity,
|
||||
needed_overlap=needed_overlap, groupby=groupby,
|
||||
refresh=refresh)
|
||||
refresh=refresh, resample=resample)
|
||||
if query is None:
|
||||
for metric in metrics:
|
||||
self._ensure_metric_is_uuid(metric)
|
||||
|
|
|
@ -148,6 +148,9 @@ class CliMeasuresShow(CliMetricWithResourceID, lister.Lister):
|
|||
help="granularity to retrieve (in seconds)")
|
||||
parser.add_argument("--refresh", action="store_true",
|
||||
help="force aggregation of all known measures")
|
||||
parser.add_argument("--resample",
|
||||
help=("granularity to resample time-series to "
|
||||
"(in seconds)"))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -159,6 +162,7 @@ class CliMeasuresShow(CliMetricWithResourceID, lister.Lister):
|
|||
stop=parsed_args.stop,
|
||||
granularity=parsed_args.granularity,
|
||||
refresh=parsed_args.refresh,
|
||||
resample=parsed_args.resample
|
||||
)
|
||||
return self.COLS, measures
|
||||
|
||||
|
@ -259,6 +263,9 @@ class CliMeasuresAggregation(lister.Lister):
|
|||
help="Attribute to use to group resources"),
|
||||
parser.add_argument("--refresh", action="store_true",
|
||||
help="force aggregation of all known measures")
|
||||
parser.add_argument("--resample",
|
||||
help=("granularity to resample time-series to "
|
||||
"(in seconds)"))
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
|
@ -279,6 +286,7 @@ class CliMeasuresAggregation(lister.Lister):
|
|||
resource_type=parsed_args.resource_type,
|
||||
groupby=parsed_args.groupby,
|
||||
refresh=parsed_args.refresh,
|
||||
resample=parsed_args.resample
|
||||
)
|
||||
if parsed_args.groupby:
|
||||
ms = []
|
||||
|
|
Loading…
Reference in New Issue