Add average calculation for allocated costs and metrics optionally in chargeback #15565
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@miq-bot assign @gtanzillo
How are metrics calculated?
let's take requested calculation
10 days x 24 Hours x 1 CPU x $1/CPU/Hour +
20 days x 24 Hours x 2 CPU x 1 CPU x $1/CPU/Hour =
$240 + $960 = $1200
(10*24*1*1) + (20*24*2*1) = $1200
Inputs
Calculation with using average
first, calculate AVG of CPU allocated metrics:
10 days * 24 hours * 1 CPU = 240
20 days * 24 hours * 2 CPU = 1200.0
and in 30 days we have 720 hours
together average is : (240 + 1200) / 720 = 1.6666666666666667
so it means that average of allocated CPUs is 1.6666666666666667 each day.
also, the value 1.67(depends on rounding) will be displayed on the monthly report in column ' vCPUs Allocated over Time Period'
and cost for the month (in a monthly report):
1.66...7 * 24 * 30 = $1200
the average is calculated on the related interval, so weekly it would be:
week:
AVG: 7 days with 1 CPU so AVG is 1 CPU
COST: 1 * 24 * 7 = $168
week:
AVG: 3 days with 1 CPU and 4 days with 2 CPU, so (3 * 1 + 4 * 2) / 7 = 1,5714285714
COST: 1,5714285714 * 24 * 7 = $263,9999999952
week:
AVG: 7 days with 2 CPU so AVG is 2 CPU
COST: 2 * 24 * 7 = $ 336
....
Calculation with using maximum
first, calculate MAX of CPU allocated metrics:
and it is 2 CPUs.
also, the value 2 will be displayed on the monthly report in column
vCPUs Allocated over Time Period
and cost for the month (in a monthly report):
2 * 24 * 30 = $1440