MetricΒΆ

class gnocchiclient.v1.metric.MetricManager(client)

Bases: gnocchiclient.v1.base.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, needed_overlap=None)

Get measurements of a 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) – aggregation to retrieve

See Gnocchi REST API documentation for the format of query dictionary http://docs.openstack.org/developer/gnocchi/rest.html#searching-for-resources

create(metric, refetch_metric=True)

Create an metric

Parameters:metric (str) – 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, resource_id=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
  • resource_id (str) – ID of the resource (required to get a metric by name)

All other arguments are arguments are dedicated to custom aggregation method passed as-is to the Gnocchi.

list()

List archive metrics

metric_url = 'v1/metric/'
resource_url = 'v1/resource/generic/%s/metric/'