Azure monitoring REST API Metrics returns only 10 resources

Sam 20 Reputation points
2024-07-02T22:54:18.74+00:00

Hi All,

I am running the API below which is supposed to return metrics for multiple VMs. However, the API is returning only 10 VMs. I have tried different subscriptions, different timespans, different intervals and all I get is only 10 VMs from multiple (yet random) resource groups.

Do you know why is this API returning only 10VMs and is there a way to fix it to return all VMs in a subscription?

From Example:

GET https://management.azure.com/subscriptions/12345678-abcd-98765432-abcdef012345/providers/microsoft.Insights/metrics?timespan=2023-06-25T22:20:00.000Z/2023-06-26T22:25:00.000Z&interval=PT5M&metricnames=Percentage CPU&aggregation=average&api-version=2021-05-01&region=eastus&metricNamespace=microsoft.compute/virtualmachines&$filter=Microsoft.ResourceId eq '*'

Documentation:

https://learn.microsoft.com/en-us/azure/azure-monitor/essentials/rest-api-walkthrough?tabs=rest%2Cportal

Thanks,
Sam

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,331 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 24,766 Reputation points MVP
    2024-07-04T06:34:28.4033333+00:00

    Hi,

    By default only 10 resources are returned. This is documented on the API top parameter : "The maximum number of records to retrieve per resource ID in the request. Valid only if filter is specified. Defaults to 10.". Try using the top parameter with higher value.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.