How do I get automated cost and usage data per hour?

Anske van Luijtelaar 25 Reputation points
2023-05-16T10:50:59.1533333+00:00

Currently, the cost exports that can be generated in the Cost Management section in the portal, have a daily granularity. However, savings plan commitments are made on an hourly basis and as such I cannot calculate the utilization % and coverage% per hour from the exports. It can only be done on the data this is pre-aggregated on the daily basis, yielding inaccurate percentages (especially when there is no good spread in compute spend over the different hours in a day...).

So my question is, where can I get cost & usage details with hour granularity, in an automated way (API query / scheduled export) so I can I calculate the CORRECT utilization & coverage percentages?

The following (purely fictive) example shows the problem. Assume, just for the sake of this example, that a day contains 5 hours and that there is a single SP commitment of USD 80 per hour.

Assume these are the usage / cost details:

hour 1: used $320 ($80 within SP that would have cost $120 ondemand, $240 outside SP, $0 unused)

hour 2: used $1 ($1 within SP that would have cost $1.5 ondemand,$0 outside SP, $79 unused)

hour 3: used $1 ($1 within SP that would have cost $1.5 ondemand,$0 outside SP, $79 unused):

hour 4: used $0 ($0 within SP that would have cost $0 ondemand,$0 outside SP, $80 unused):

hour 5: used $10 ($10 within SP that would have cost $15 ondemand,$0 outside SP, $70 unused)

When calculating utilization and coverage, it would yield the following stats:

hr1: coverage $120/ ($120 + $240) = 33%, utilization = ($80-$0)/$80 = 100%

hr2: coverage $1.5/($1.5+$0) = 100%, utilization = ($80-$79)/$80 = 1.25%

hr3: coverage 100%, utilization 1.25%

hr4: coverage 100%, utilization 0%

hr5: coverage 100%, utilization 1.25%

However, as the cost exports have only data aggregated on the day, the following stats are calculated for the day:

utilization = ($400) - ($0+$79+$79+$80+$70) / $400 = (400-308)/400 = 23%

coverage = 120+1.5+1.5+0+15 / (138 + 240) = 138/378 = 36.5%

These are, as one can see, not very informative numbers. When the average over all 5 hours in the day are calculated, especially the coverage % is very different:

utilization 20.75%

coverage 86.6%

So my question is, where can I get cost & usage details with hour granularity, in an automated way (API query / scheduled export) so I can I calculate the CORRECT utilization & coverage percentages per hour?

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
2,315 questions
{count} vote

Accepted answer
  1. SadiqhAhmed-MSFT 40,986 Reputation points Microsoft Employee
    2023-05-16T17:22:33.96+00:00

    Hello @Anske van Luijtelaar Thank you for reaching out to us on Microsoft Q&A platform. Happy to answer any questions you may have!

    I understand that you are looking to get cost & usage details with hour granularity through automation (API or schedule exports). Hourly granularity is not supported. We are evaluating this and don’t have a concrete ETA at this time.

    Unfortunately, there is no workaround for hourly utilization data at resource level.  Customers can get hourly summary charges of all SavingsPlan eligible Compute usage using following: 

    Savings Plan recommendations API Benefit Recommendations - List - REST API (Azure Cost Management) | Microsoft Learn supports allRecommendationDetails option that will return an array of On-demand charges (of all SavingsPlan eligible Compute usage for given scope) for each hour between firstConsumptionDate and lastConsumptionDate that were used for computing benefit recommendations.

    Hope this answers your question. Let us know if you have any questions!


    If the response helped, do "Accept Answer" and up-vote it

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful