Reputation: 15
I'm working on a KQL script to retrieve all kind of information from a Azure VM, what I would like to retrieve is:
Most of them are working fine in below script, however, now I want to add the CPU and memory information to this list. Is there a way that I can extract those 2 out of the vmSize information? Or is there any other way?
resources
| where type == "microsoft.compute/virtualmachines"
| join kind=leftouter (resourcecontainers | where type == "microsoft.resources/subscriptions" | project subscription = name, subscriptionId) on subscriptionId
| extend nicId = tostring(properties.networkProfile.networkInterfaces[0].id)
| join kind=leftouter (resources | where type == 'microsoft.network/networkinterfaces' | project nicId = id, privateIPAllocation = properties.ipConfigurations[0].properties.privateIPAllocationMethod, privateIPAddress = properties.ipConfigurations[0].properties.privateIPAddress) on nicId
| project name, subscription, resourceGroup, location, zones, properties.provisioningState, properties.hardwareProfile.vmSize, properties.extended.instanceView.osName, properties.extended.instanceView.osVersion, properties.extended.instanceView.powerState.displayStatus, properties.licenseType, nicId, privateIPAllocation, privateIPAddress
From all tests that I've performed the CPU and memory information remains empty or returns null
Upvotes: 0
Views: 1727
Reputation: 7725
KQL script to retrieve information from Azure VM
Here are the steps to retrieve the VM information using KQL Log Query.
Create a Log Analytics Work Space
Go to Monitor in the Azure portal, select Virtual Machines > Not monitored and select your VM > Enable > select your existing Log Analytics Work Space.
After completing the deployment, wait for some time for the data to be sent to Log Analytics Work Space.
Go to Log Analytics Work Space and select Logs. Then run the following KQL query.
VMComputer
| project DisplayName, AzureLocation, AzureResourceGroup, PhysicalMemoryMB,Cpus,Ipv4Addresses
Here is the result
Upvotes: 0