Jump to: navigation, search

Difference between revisions of "Ceilometer/ComplexFilterExpressionsInAPIQueries/ComplexFilterExpressionsInStatistics"

(REST resource)
(API examples)
Line 26: Line 26:
 
= Future improvements =
 
= Future improvements =
 
= API examples =
 
= API examples =
 +
Consider a requirement for determining, for some tenant, the number of distinct instances (cardinality) as well as the total number of instance samples (count). You might also want to see this information with 15 minute long intervals. Then, using current API the query would look like the following:
 +
<pre>
 +
GET /v2/meters/instance/statistics?aggregate.func=cardinality
 +
                                  &aggregate.param=resource_id
 +
                                  &aggregate.func=count
 +
                                  &groupby=project_id&period=900
 +
</pre>
 +
 +
With the new API it would look like the following
 +
<pre>
 +
POST /v2/query/samples/statistics
 +
</pre>
 +
With the body:
 +
<pre>
 +
{
 +
filter: {"=": {"counter_name": "instance"}},
 +
aggregates: [{"func": "cardinality", "param": ["resource_id"]}, {"func": "count", "param": []}],
 +
groupby: ["project_id"],
 +
period: 900,
 +
}
 +
</pre>

Revision as of 16:17, 14 April 2014

Architecture

REST resource

The new solution includes new REST resources for provide complex queries for sample statistics:

REST Resource Functionality Returned Object Type
'/query/samples/statistics' retrieve statistics of samples for meter(s) Statistics

As new resource is defined, the simple statistics query support remained as it is now, which means that the API is backward compatible and also a new query grammar could be defined without limitations.

POST request

Filter Expression Language

The same expression language is used as in Ceilometer/ComplexFilterExpressionsInAPIQueries#Filter_Expression_Language

Group by

Order by

Limit

Supported DB drivers

Future improvements

API examples

Consider a requirement for determining, for some tenant, the number of distinct instances (cardinality) as well as the total number of instance samples (count). You might also want to see this information with 15 minute long intervals. Then, using current API the query would look like the following:

GET /v2/meters/instance/statistics?aggregate.func=cardinality
                                  &aggregate.param=resource_id
                                  &aggregate.func=count
                                  &groupby=project_id&period=900

With the new API it would look like the following

POST /v2/query/samples/statistics

With the body:

{
filter: {"=": {"counter_name": "instance"}},
aggregates: [{"func": "cardinality", "param": ["resource_id"]}, {"func": "count", "param": []}],
groupby: ["project_id"],
period: 900,
}