Metrics API Client

class go_http.metrics.MetricsApiClient(auth_token, api_url=None, session=None)

Client for Vumi Go’s metrics API.

Parameters:
  • auth_token (str) – An OAuth 2 access token. NOTE: This will be replaced by a proper authentication system at some point.
  • api_url (str) – The full URL of the HTTP API. Defaults to https://go.vumi.org/api/v1/go.
  • session (requests.Session) – Requests session to use for HTTP requests. Defaults to a new session.
fire(metrics)

Fire metrics.

Parameters:metrics (dict) – A mapping of metric names to floating point metric values.

When metrics are fired they must specify an aggregator. The aggregation method is determined by the suffix of the metric name. For example, foo.last fires a metric that uses the last aggregation method.

If a metric name does not end in a valid aggregator name, firing the set of metrics will fail.

The available aggregators are:

Average:avg. Aggregates by averaging the values in each time period.
Sum:sum. Aggregates by summing all the values in each time period.
Maximum:max. Aggregates by choosing the maximum value in each time period.
Minimum:min. Aggregates by choosing the minimum value in each time period.
Last:last. Aggregates by choosing the last value in each time period.

Note that metrics can also be fired via an HTTP conversation API. See go_http.send.HttpApiSender.fire_metric().

get_metric(metric, start, interval, nulls, end=None)

Get a metric.

Parameters:
  • metric (str) – Metric name.
  • start (str) – How far back to get metrics from (e.g. -30d).
  • interval (str) – Bucket size for grouping (e.g. 1d).
  • nulls (str) – How nulls should be handled (e.g. omit).
  • end (str) – When to get metrics until (e.g. -30d).