kqlutilization

KQL query returns available memory but not Total Memory


When i run this KQL query it does not return total memory of a VM just the available memory.

I am trying to calculate the % available memory but i cant without the total memory on the VM.

What am i doing wrong? I have validated the available memory which appears to be accurate.

Memory


Solution

  • KQL query returns available memory but not Total Memory

    You can use below KQL query to fetch the VM Total memory, free memory and percentage of free memory

    InsightsMetrics
    | where Origin == "vm.azm.ms" and Namespace == "Memory"
    | extend TotalMemoryGB=(todynamic(Tags)["vm.azm.ms/memorySizeMB"])/(1000)
    | summarize AailableMemoryGB = avg(Val)/(1000) by Computer, TotalMemoryGB, _ResourceId
    | extend Availabile_Memory_Percentage=(AailableMemoryGB/TotalMemoryGB)*100
    | project Computer, TotalMemoryGB, AailableMemoryGB,Availabile_Memory_Percentage
    

    Output:

    enter image description here

    Reference: KQL Query Free Disk Space