Use FlexReports to calculate Azure Reserved Instance benefits
search cancel

Use FlexReports to calculate Azure Reserved Instance benefits

book

Article ID: 377834

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

The Cost Management dataset can be used to calculate the Cost Before RI and Savings from RI metrics.

Resolution

Using the following FlexReport query will give you the cost before RI and Savings from RI:

{
  "sqlStatement": " SELECT timeInterval_Month AS Month, SUM(CostInReportingCurrency) AS SUM_CostInReportingCurrency, SUM(Quantity) AS SUM_Quantity, ResourceName AS ResourceName, SubscriptionName AS SubscriptionName, ResourceGroup AS ResourceGroup, MeterName AS MeterName, ResourceLocation AS ResourceLocation, UnitPrice AS UnitPrice, PaygPrice AS PaygPrice, ROUND(UnitPrice * SUM(Quantity), 2) AS CostBeforeRI, ROUND( ( UnitPrice * SUM(Quantity) - SUM(CostInReportingCurrency) ), 2 ) AS SavingsFromRI, ROUND( ( (UnitPrice * SUM(Quantity)) - SUM(CostInReportingCurrency) ) / (UnitPrice * SUM(Quantity)) * 100, 2 ) AS Savings_Percentage FROM AZURE_COST_USAGE WHERE (PricingModel IN ('Reservation')) AND (MetricType LIKE '%Amortized%') AND (ConsumedService LIKE '%Microsoft.Compute%') GROUP BY timeInterval_Month, ResourceName, SubscriptionName, ResourceGroup, ResourceLocation, UnitPrice, PaygPrice, MeterName ORDER BY SUM_Quantity DESC ",
  "needBackLinkingForTags": true,
  "dataGranularity": "MONTHLY",
  "timeRange": {
    "last": 1,
    "excludeCurrent": true
  },
  "limit": -1
}