Add event analysis to cloudkitty for rating second level

Registered by zhangguoqing

The blueprint will description that add event analysis to cloudkitty for rating second level.
(1) The current cloudkitty rating strategy and problem
Now, we usually use the ceilometer or gnocchi of the cloudkitty collector to get the services measurement and resource data for rating, which always likely a periodic task at default period 3600s(one hour).

The implemented rating services include compute, image, volume,,, network.floating, and all of them can be divided into two classes. The and can be classified as a class what those services cost only depend on the measurement value, that means the time and status are unconcerned [type1]. Other services are not only related with the measurement value but also the resource status in a period [type2]. For instance with volume, the size is a key measurement value for rating, but if a volume is resize to another size in one rating cycle, we should cut this cycle to two time slices. For another example with compute, the flavor always is a key resource attribute for an instance rating, but the instance has been deleted at the beginning of current cycle, if we calculate the full cost period is not reasonable distinctly. There is the same problem with image, network.floating and volume.

All of above expound, it can come a conclusion that we should think about the resource status when generate service cost at every rating cycle.

(2) The solution of rating second level.
One solution obtain more accurately cost is cut down the period time to avoid many times status change in a rating cycle, but we can not shorten the period value too small to complete the rating task for all resources in one cycle. So it is not feasible.

Another solution to improve the granularity of rating to second level with more accurately, we should focus on the event analysis for the [type2] service in a rating period. We can know all resource status changes by event analysis, then obtain more accurately resource cost.

An instance rating scenario, which is reference to .
some parameters: flavor-A = 5$/hour; flavor-B = 10$/hour; period = 3600s
One day we create a instance with flavor-A at 13:15:10; then we change the instance to flavor-B at 13:45:13; then we shut down it at 14:10:59; then start it at 14:35:20; delete it at 14:49:13.
We can get the corresponding event analysis as follow:
1)compute.instance.create at 13:15:10
2)compute.instance.resize at 13:45:13
3)compute.instance.power_off at 14:10:59
4)compute.instance.power_on at 14:35:20
5)compute.instance.delete at 14:49:13
We can get the result without event analysis:
Begin End Unit Unit Price(per hour) Rate
13:00:00 14:00:00 instance:flavor-B 10 10
14:00:00 15:00:00 instance:flavor-B 10 10

We can get the result with event analysis
Begin End Unit Price Rate comment
13:15:10 13:45:13 instance:flavor-A 5 2.5 begin:instance.create
13:45:13 14:00:00 instance:flavor-B 10 2.46 begin:instance.resize
14:00:00 14:10:59 instance:flavor-B 10 1.83 begin:period_cutting_event
14:10:59 14:35:20 instance:flavor-B 10 0 begin:instance.power_off
14:35:20 14:49:13 instance:flavor-B 10 2.31 begin:instance.power_on

(3) The draft of code structure.
enabled = False
event_backend = noop/ceilometer/panko

cloudkitty.event.backends =
    noop = cloudkitty.event.noop:NoopEventAnalysis
    ceilometer = cloudkitty.event.ceilometer:CeilometerEventAnalysis
    panko = cloudkitty.collector.panko:PankoEventAnalysis

The round logic of adding event analysis to collector logic
1) Get all events duration of every current rating cycle by event backend.
2) Match the [type2] service rating resource with relevant events.
3) Cut the resource rating time to some slices base on their event change in this cycle.
4) Ttransformer the collector data to format data.
5) Return the format data, which a resource may has multi items.

Another notes:
1) Specify some events for resource in configuration file.
2) The cloudkitty storage will be changed to storage new form rating data.
3) The docs should add some related description about event analysis module.

Blueprint information

Not started
Series goal:
Milestone target:

Related branches



Gerrit topic:,topic:bp/rating-for-second-level,n,z

Addressed by:
    Add event analysis to cloudkitty for rating second level


Work Items

This blueprint contains Public information 
Everyone can see this information.


No subscribers.