What’s the best way to get a report showing cost history for every VM in Azure?
search cancel

What’s the best way to get a report showing cost history for every VM in Azure?

book

Article ID: 282857

calendar_today

Updated On:

Products

CloudHealth

Issue/Introduction

The ARM Virtual Machine Hours report shows each VM and the cost for that month along with other data points. As the report shows costs for the current month, each month would need to be downloaded separately.

Another option is to use a FlexReport listing each VM by Instance ID. The screenshot below shows the Dimensions, Measures and Filters for a report.

 

Azure-FlexReport-Cost_per_VM.png

 

The report query is provided here to copy and paste into a FlexReport:

{
"sqlStatement": "SELECT timeInterval_Month ASMonth, SUM(azure_Cost) AS SUM_Azure_Cost, SUM(azure_ConsumedQuantity) AS SUM_Azure_Consumed_Quantity, split_part(azure_InstanceId, '/', 9) AS Azure_VM_Name FROM AZURE_EA WHERE (azure_ConsumedService IN ('Microsoft.Compute') AND split_part(azure_InstanceId, '/', 8) IN ('virtualMachines') AND (Azure_MeterCategory IN ('Virtual Machines'))) GROUPBY timeInterval_Month, split_part(azure_InstanceId, '/', 9)",
"needBackLinkingForTags": true,
"dataGranularity": "MONTHLY",
"timeRange": {
"last": 1,
"excludeCurrent": true
},
"limit": -1
}