The gnocchiclient.v1.metric
Module¶
- class gnocchiclient.v1.metric.MetricManager(client)¶
Bases:
Manager
- add_measures(metric, measures, resource_id=None)¶
Add measurements to a metric.
- Parameters:
metric (str) – ID or Name of the metric
resource_id (str) – ID of the resource (required to get a metric by name)
measures (list of dict(timestamp=timestamp, value=float)) – measurements
- aggregation(metrics, query=None, start=None, stop=None, aggregation=None, reaggregation=None, granularity=None, needed_overlap=None, resource_type='generic', groupby=None, refresh=False, resample=None, fill=None)¶
Get measurements of an aggregated metrics.
- Parameters:
metrics – IDs of metric or metric name
query (dict) – The query dictionary
start (timestamp) – beginning of the period
stop (timestamp) – end of the period
aggregation (str) – granularity aggregation function to retrieve
reaggregation (str) – groupby aggregation function to retrieve
granularity (int) – granularity to retrieve (in seconds)
needed_overlap (float) – percent of datapoints in each metrics required
resource_type (str) – type of resource for the query
groupby (list) – list of attribute to group by
refresh (bool) – force aggregation of all known measures
resample (float) – resample measures to new granularity
fill (float or 'null') – value to use when backfilling missing datapoints
See Gnocchi REST API documentation for the format of query dictionary http://docs.openstack.org/developer/gnocchi/rest.html#searching-for-resources
- batch_metrics_measures(measures)¶
Add measurements to metrics.
- Parameters:
measures – measurements
- batch_resources_metrics_measures(measures, create_metrics=False)¶
Add measurements to named metrics if resources.
- Parameters:
measures – measurements
- create(metric=None, refetch_metric=True, name=None, archive_policy_name=None, resource_id=None, unit=None)¶
Create an metric.
- Parameters:
name (str) – Metric name.
archive_policy_name (str) – Archive policy name.
resource_id (str) – The resource ID to attach the metric to.
unit (str) – The unit of the metric.
- delete(metric, resource_id=None)¶
Delete an metric.
- Parameters:
metric (str) – ID or Name of the metric
resource_id (str) – ID of the resource (required to get a metric by name)
- get(metric, resource_id=None)¶
Get an metric.
- Parameters:
metric (str) – ID or Name of the metric
resource_id (str) – ID of the resource (required to get a metric by name)
- get_measures(metric, start=None, stop=None, aggregation=None, granularity=None, resource_id=None, refresh=False, resample=None, **kwargs)¶
Get measurements of a metric.
- Parameters:
metric (str) – ID or Name of the metric
start (timestamp) – beginning of the period
stop (timestamp) – end of the period
aggregation (str) – aggregation to retrieve
granularity (int) – granularity to retrieve (in seconds)
resource_id (str) – ID of the resource (required to get a metric by name)
refresh (bool) – force aggregation of all known measures
resample (float) – resample measures to new granularity
All other arguments are arguments are dedicated to custom aggregation method passed as-is to the Gnocchi.
- list(limit=None, marker=None, sorts=None)¶
List metrics.
- Parameters:
limit (int) – maximum number of resources to return
marker (str) – the last item of the previous page; we return the next results after this value.
sorts (list of str) – list of resource attributes to order by. (example [“user_id:desc-nullslast”, “project_id:asc”]
- metric_batch_url = 'v1/batch/metrics/measures'¶
- metric_url = 'v1/metric/'¶
- resource_url = 'v1/resource/generic/%s/metric/'¶
- resources_batch_url = 'v1/batch/resources/metrics/measures'¶