Azure Get Utilization Data and usage % for multiple VMs with Rest API

Sam 0 Reputation points
2024-05-10T19:19:34.8266667+00:00

Hi All,

I am trying to get all or multiple VM usage/utilization data from Azure. The API below provides CPU % for 1 VM at a time:

  1. Is there a way to get multiple or all VMs in a subscription with one API?
  2. Is there a way to include other metrics like disk operations or CPU Min/Max?

Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/linux/metrics-vm-usage-rest

https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmname}/providers/microsoft.insights/metrics?api-version=2018-01-01&metricnames=Percentage%20CPU

Thanks,
Sam

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,271 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. hossein jalilian 4,205 Reputation points
    2024-05-11T00:59:17.14+00:00

    Hello Sam,

    Thanks for posting your question in the Microsoft Q&A forum.

    Here's how you can achieve this:

    This API allows you to retrieve the instance view of multiple VMs in a single request.

    GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/instanceView?api-version=2021-07-01
    
    
    • To include additional metrics like disk operations and CPU min/max, you can use the "expand" parameter in the AP

    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful

    1 person found this answer helpful.