Azure api to get metrics data for multiple Virtual Machines

Ashish Sharma 6 Reputation points
2020-09-14T07:28:23.627+00:00

Hi,

I am looking for the azure rest api to get performance metrics data for multiple resources (VMs) in a single request.

I went through the documentation and found that the Get request for only one VM per request-

https://management.azure.com/subscriptions/{SubscriptionID}/resourceGroups/{ResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{VM Name}/providers/microsoft.insights/metrics?api-version=2019-07-01&metricnames=Percentage CPU

Please suggest.

Thanks
Ashish

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,989 questions
Azure Health Data Services
Azure Health Data Services
An Azure offering that provides a suite of purpose-built technologies for protected health information in the cloud.
166 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Stanislav Zhelyazkov 24,611 Reputation points MVP
    2020-09-15T06:54:36.047+00:00

    Hi,
    You can use the same API but not provide the part about the VM. Keep in mind that the API works only for VMs and a few other resources at subscription level and you need to provide region. You can only get the metrics for all VMs in a subscription in one region. If you have VMs in another region you need to make separate call.

    Example call with ARM client is:

    armclient get "/subscriptions/<sub id>/providers/microsoft.Insights/metrics?timespan=2020-09-14T06:30:00.000Z/2020-09-15T06:45:00.000Z&interval=PT15M&metricnames=Percentage CPU&aggregation=average&metricNamespace=microsoft.compute%2Fvirtualmachines&top=10&orderby=average desc&autoadjusttimegrain=true&validatedimensions=false&api-version=2017-12-01-preview&region=westeurope"
    

    (Please mark the reply as answer if it is the solution to your problem.


  2. Ashish Sharma 6 Reputation points
    2020-09-15T08:30:32.53+00:00

    Hi Stan,

    By using the suggested api we are not able to track VM wise metrics data for a subscription.

    e.g. A subscription has multiple VMs and we need the metrics value for each VM for that subscription in a single request.

    Please suggest.

    Thanks,
    Ashish

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.