How to get Azure Insights data via Azure CLI

MrB1963 61 Reputation points
2023-03-16T12:41:32.5833333+00:00

Hello,

What i am trying to figure out is how i can gather vm data through the CLI. For instance is there a way to get total used space from a vm memory etc through the CLI? I know i can call a PowerShell script to do that but i need something that will work both in linux and windows. I know this data sitting there in azure insights. How can i show that data through the CLI. If you need any more information, please let me know.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
2,798 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,113 questions
{count} votes

Accepted answer
  1. deherman-MSFT 33,296 Reputation points Microsoft Employee
    2023-03-22T17:53:38.0433333+00:00

    @MrB1963

    You can use az monitor metrics list to view certain metrics for the VM. This will fetch you the Percentage CPU for a VM: "

    az monitor metrics list --resource /subscriptions/{subscriptionID}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{resourceName} --metric "Percentage CPU" --interval "PT1M"
    

    However, "Logical Disk Space" is not a metric available here. To get the VM Insights data you will need to utilize Kusto Queries to fetch the information. See How to query logs from VM insights for information on how to utilize this VM Insights data. You can utilize the CLI command az monitor log-analytics query with this information.

    Hope this helps. Let me know if you still have questions or need further assistance.


    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.


0 additional answers

Sort by: Most helpful