Warning
This backend is considered unstable and should be used for upstream development only.
In order to implement a storage backend for cloudkitty, you’ll have to implement the following abstract class:
cloudkitty.storage.v2.
BaseStorage
(*args, **kwargs)[source]¶Abstract class for v2 storage objects.
get_retention
()[source]¶Returns the retention period defined in the configuration.
Return type: | datetime.timedelta |
---|
push
(dataframes, scope_id=None)[source]¶Pushes dataframes to the storage backend
A dataframe has the following format:
{
"usage": {
"bananas": [ # metric name
{
"vol": {
"unit": "banana",
"qty": 1
},
"rating": {
"price": 1
},
"groupby": {
"xxx_id": "hello",
"yyy_id": "bye",
},
"metadata": {
"flavor": "chocolate",
"eaten_by": "gorilla",
},
}
],
"metric_name2": [...],
}
"period": {
"begin": "1239781290", # timestamp
"end": "1239793490", # timestamp
}
}
Parameters: | dataframes (list) – List of dataframes |
---|
retrieve
(begin=None, end=None, filters=None, group_filters=None, metric_types=None, offset=0, limit=1000, paginate=True)[source]¶Returns the following dict:
{
'total': int, # total amount of measures found
'dataframes': list of dataframes,
}
Parameters: |
|
---|---|
Return type: | dict |
total
(groupby=None, begin=None, end=None, metric_types=None, filters=None, group_filters=None, offset=0, limit=1000, paginate=True)[source]¶Returns a grouped total for given groupby.
Parameters: |
|
---|---|
Return type: | dict |
Returns a dict with the following format:
{
'total': int, # total amount of results found
'results': list of results,
}
Each result has the following format:
{
'begin': XXX,
'end': XXX,
'rate': XXX,
'groupby1': XXX,
'groupby2': XXX
}
You’ll then need to register an entrypoint corresponding to your storage
backend in the cloudkitty.storage.v2.backends
section of the setup.cfg
file.
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.