Is there a way to export Monitor metrics for all VMs (CPU utilization, Memory etc) at once?

Alberto Mijares (Tantius) 81 Reputation points
2022-09-06T20:32:10.19+00:00

I need to query all the VMs metrics that Monitor has at the same time (CPU, memory etc) to obtain utilization by hour.
I can accomplish this in AWS with Cloudwatch metric math but I'm having difficulty doing the same in Azure. The only way I have been able to identify is going resource by resource but that creates a high number of calls.

thank you

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

2 answers

Sort by: Most helpful
  1. Alistair Ross 7,101 Reputation points Microsoft Employee
    2022-09-06T20:46:01.57+00:00

    Hi @Alberto Mijares (Tantius)

    If you are trying to export the metrics via the metrics API, then the answer is no. This request is done per resource.

    If you are sending the metrics to Log Analytics, then you can query the logs via the query API. The results of this can be shaped to your requirements. Please note that there is still limits, such as

    • Maximum records returned in a single query: 500,000
    • Maximum size of data returned: ~104 MB / ~100 MiB (The API returns up to 64 MB of compressed data, which translates to up to 100 MB of raw data.)
    • Maximum query running time: 10 minutes
    • Maximum request rate: 200 requests per 30 seconds per Azure AD user or client IP address

    I hope this answers your question.

    Alistair

    2 people found this answer helpful.

  2. kobulloc-MSFT 23,341 Reputation points Microsoft Employee
    2022-09-08T04:04:16.847+00:00

    Hello, @Alberto Mijares (Tantius) !

    Outside of using the metrics API as mentioned by @Alistair Ross , there are a number of options available for viewing VM metrics (including CPU and memory) at once that may work for you.

    How do I view or export Azure Monitor metrics (CPU utilization, Memory, etc.) for all VMs at once?
    There are a good number of options when it comes to viewing Azure Monitor metrics for your VMs. These are just a couple:

    1. Custom Dashboards and Azure Metrics Explorer
    Dashboards are extremely helpful when collecting data and creating your own custom dashboard is a good way to get exactly the information you are interested in, especially if you pin a custom query. Here I've created a custom dashboard to show Average CPU Percentage as well as Average Available Memory for two VMs that are in different regions (and in separate scopes):

    Create a dashboard in the Azure portal
    View multiple resources in the Azure metrics explorer

    1. Go to the VM resource that you are interested in
    2. Go to Monitoring > Metrics
    3. Select the scope you are interested in
    4. Configure the filters to show the data you would like to see
    5. Click on Save to dashboard and then select Pin to dashboard
    6. Either use an existing dashboard or create a new dashboard
    7. Pin additional metrics from other resources/scopes as needed

    238847-image.png

    2. VM Insights
    VM Insights includes pre-built workbooks that allow you to monitor your entire set of Azure and hybrid virtual machines in a single interface. While there is no direct cost for VM insights, you are charged for its activity in the Log Analytics workspace. Here I've added two VMs from two separate resource groups into a workspace and I'm showing data for each VM's CPU utilization percentage. Note that I can filter by subscription, resource group, specific VMs, workspace locations, or workspaces as I am in this example:

    VM Insights Overview

    1. From the portal, search for Monitor
    2. Select VM Insights from the overview page by clicking on View
    3. Enable VM Insights by clicking on Configure Insights
    4. Under Virtual Machines, view Not monitored and expand the resource groups with your VMs
    5. Click on Enable to enable VM Insights
    6. Configure monitoring (I used the same data collection rule)
    7. Click on the Performance tab under Virtual Machines
    8. Select Performance under View Workbooks > Performance Analysis
    9. Filter according to your needs (subscription, resource groups, VMs, workspaces, etc.)

    238758-image.png

    3. Log Analytics and Custom Queries
    This is probably the best option for what you are looking for but it does require a bit more query knowledge to fully take advantage of although the built in queries will address things like CPU usage and memory. If you are looking for a custom query, let us know so we can assist you with the Kusto (KQL) needed.

    238824-image.png

    Additional Reading:

    0 comments No comments