Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add average calculation for allocated costs and metrics optionally in chargeback #15565

Merged
merged 4 commits into from
Jul 21, 2017

Conversation

lpichler
Copy link
Contributor

@lpichler lpichler commented Jul 13, 2017

@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

  • Hourly rate $1 (we are calculation in hourly rate, so no conversion is needed here )
  • let's take the month of 30 days
  • 1 CPU was allocated in first 10 days in a month
  • 2 CPUs were allocated in last 20 days

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:

  1. week:
    AVG: 7 days with 1 CPU so AVG is 1 CPU
    COST: 1 * 24 * 7 = $168

  2. 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

  3. 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

@lpichler lpichler changed the title [WIP] Add average calculation for allocated cost and metrics optionally in chargeback [WIP] Add average calculation for allocated costs and metrics optionally in chargeback Jul 13, 2017
@miq-bot miq-bot added the wip label Jul 13, 2017
lpichler added 3 commits July 20, 2017 18:43
this parameter is for determination which
method will be used for calculation.
We can use average or maximum,
@lpichler lpichler force-pushed the optionable_allocated_calculation branch from f4c11a6 to 9fddbdc Compare July 20, 2017 16:49
@lpichler lpichler changed the title [WIP] Add average calculation for allocated costs and metrics optionally in chargeback Add average calculation for allocated costs and metrics optionally in chargeback Jul 20, 2017
@lpichler lpichler force-pushed the optionable_allocated_calculation branch from 9fddbdc to 02a9a47 Compare July 20, 2017 16:50
@miq-bot miq-bot removed the wip label Jul 20, 2017
@lpichler
Copy link
Contributor Author

@miq-bot remove_label wip

@miq-bot
Copy link
Member

miq-bot commented Jul 20, 2017

Checked commits lpichler/manageiq@529b0cd~...02a9a47 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
5 files checked, 0 offenses detected
Everything looks fine. ⭐

@gtanzillo gtanzillo added this to the Sprint 65 Ending Jul 24, 2017 milestone Jul 21, 2017
@gtanzillo gtanzillo merged commit d7be775 into ManageIQ:master Jul 21, 2017
@lpichler lpichler deleted the optionable_allocated_calculation branch July 23, 2017 08:55
@Loicavenel
Copy link

@lpichler @gtanzillo could you confirm this will work only with Allocation?

@Loicavenel
Copy link

@lpichler btw, 20 days * 24 hours * 2 CPU = 1200.0 is wrong, it is 960 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants