The Module

MongoDB storage backend



Put the data into a MongoDB database


- meter
  - the raw incoming data
- resource
  - the metadata for resources
  - { _id: uuid of resource,
      metadata: metadata dictionaries
      user_id: uuid
      project_id: uuid
      meter: [ array of {counter_name: string, counter_type: string,
                         counter_unit: string} ]

Clear expired data from the backend storage system.

Clearing occurs with native MongoDB time-to-live feature.

get_meter_statistics(sample_filter, period=None, groupby=None, aggregate=None)[source]

Return an iterable of models.Statistics instance.

Items are containing meter statistics described by the query parameters. The filter must have a meter value set.

get_resources(user=None, project=None, source=None, start_timestamp=None, start_timestamp_op=None, end_timestamp=None, end_timestamp_op=None, metaquery=None, resource=None, limit=None)[source]

Return an iterable of models.Resource instances

  • user – Optional ID for user that owns the resource.
  • project – Optional ID for project that owns the resource.
  • source – Optional source filter.
  • start_timestamp – Optional modified timestamp start range.
  • start_timestamp_op – Optional start time operator, like gt, ge.
  • end_timestamp – Optional modified timestamp end range.
  • end_timestamp_op – Optional end time operator, like lt, le.
  • metaquery – Optional dict with metadata to match on.
  • resource – Optional resource filter.
  • limit – Maximum number of results to return.

Record the metering data in batch.

Parameters:samples – a list of samples dict.
static update_ttl(ttl, ttl_index_name, index_field, coll)[source]

Update or create time_to_live indexes.

  • ttl – time to live in seconds.
  • ttl_index_name – name of the index we want to update or create.
  • index_field – field with the index that we need to update.
  • coll – collection which indexes need to be updated.

Previous topic

The Module

Next topic

The Module

Project Source

This Page