Is there a way to use a FlexReport to calculate Azure Reserved Instance benefit
search cancel

Is there a way to use a FlexReport to calculate Azure Reserved Instance benefit

book

Article ID: 377834

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

You use the Cost Management dataset to calculate the cost before RI and Savings from RI

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
}