SOLVED

VM details query

%3CLINGO-SUB%20id%3D%22lingo-sub-1221810%22%20slang%3D%22en-US%22%3EVM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1221810%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Team%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETrying%20to%20query%20VM%20details%20using%20KQL%20but%20unable%20to%20include%20different%20thing%20in%20query.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EVMComputer%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20_ResourceId%20!%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%20%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20TimeGenerated%2C%20HostName%2C%20AzureImageSku%2C%20AzureResourceGroup%2C%20AzureLocation%2C%20AzureSize%2C%20Cpus%2C%20DependencyAgentVersion%2C%20PhysicalMemoryMB%2C%20OperatingSystemFamily%2C%20OperatingSystemFullName%2C%20VirtualMachineType%2C%20VirtualizationState%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EUnable%20to%20include%20IPaddress%20details%20in%20it%20which%20can%20be%20seen%20using%20%3A%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Eproject%3C%2FSPAN%3E%3CSPAN%3E%20Computer%2C%20Ipv4Addresses%2C%20Ipv4DefaultGateways%2C%20Ipv4SubnetMasks%2C%20MacAddresses%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAlso%2C%20it%20doesn't%20have%20a%20state%20of%20VM%20like%20Running%20or%20Stopped%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ECan%20someone%20help%20to%20include%20them%20in%20one%20query%3F%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3EThanks%20in%20advance.%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1221810%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20Log%20Analytics%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EQuery%20Language%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1222442%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1222442%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380509%22%20target%3D%22_blank%22%3E%40Rahul_Mahajan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThose%20data%20types%20are%20arrays%2C%20so%20need%20to%20be%20strings%20at%20the%20end%20of%20a%20%3CSTRONG%3ESummarize%20-%20%3C%2FSTRONG%3EI%20used%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fquery%2Ftostringfunction%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3Etostring%3C%2FA%3E%20to%20allow%20this%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA2WQS0%25252FDMBCE7%25252F0VS08g%25252BciVQ2hFiEQAkSpX5CZDYjV%25252ByA8qR%25252Fx4TAhCafbmndlvZ12XOy1N8LCbLzr3sKD3NzgdbIOipas72m6T4oKU3IoRdIx0EBI5FCz3aBk9auefuQSjbAwWheQdqlOYn3%25252Bw3Opg2IaWNVmedMO90GqeqNIaRjsTHKM9DFQL1cSsg%25252FI1rJuMl5zXPjrR8KGE1DaW94xezE8%25252BoboqOg%25252F5wKUY4rodhuE3%25252ByWxFtaHBORNLxQO0STP3BPjFLfy6f7VRT79hk3868J83mZta%25252BEc3A1bCnt88DD4PBHOPK7kKhwVfMndaSGlMP%25252FEb%25252FiKGa%25252B6AQAA%2Ftimespan%2FP1D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EVMComputer%0A%7C%20where%20_ResourceId%20!%3D%20%22%22%0A%7C%20summarize%20by%20TimeGenerated%2C%20HostName%2C%20AzureImageSku%2C%20AzureResourceGroup%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AzureLocation%2C%20AzureSize%2C%20Cpus%2C%20DependencyAgentVersion%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PhysicalMemoryMB%2C%20OperatingSystemFamily%2C%20OperatingSystemFullName%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20VirtualMachineType%2C%20VirtualizationState%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tostring(Ipv4Addresses)%2C%20tostring(Ipv4DefaultGateways)%2C%20tostring(Ipv4SubnetMasks)%2C%20tostring(MacAddresses)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EI%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1224294%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1224294%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20ton%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F436985%22%20target%3D%22_blank%22%3E%40CLIVE_Watson%3C%2FA%3E%3CBR%20%2F%3E%3CBR%20%2F%3EOne%20more%20thing..%20can%20you%20please%20help%20to%20get%20VM%20disk%20size%20and%20state%20added%20like%20stopped%20or%20running%20as%20I%20am%20not%20able%20to%20find%20any%20details%20in%20it%20for%20that.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eor%20suggest%20any%20other%20query%20which%20will%20have%20all%20these%20details.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1224467%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1224467%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380509%22%20target%3D%22_blank%22%3E%40Rahul_Mahajan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20running%20state%20if%20you%20don't%20have%20it%20in%20any%20of%20your%20tables%20(its%20not%20a%20default%20for%20logging)%20then%20you%20have%20to%20create%20a%20test.%26nbsp%3B%20Here%20I'm%20joining%20the%20data%20to%20the%20Heartbeat%20Table%20as%20%3CSTRONG%3Eall%3C%2FSTRONG%3E%20Log%20Analytics%20computers%20will%20have%20this%20(you%20may%20wish%20to%20use%20another%20Table%20instead%20or%20in%20addition).%26nbsp%3B%20Its%20a%20basic%20test%20as%20a%20Server%20could%20be%20up%20but%20the%20agent%20not%20sending%20data.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-cpp%22%3E%3CCODE%3E%2F%2F%20left%20Table%0AVMComputer%0A%7C%20where%20_ResourceId%20!%3D%20%22%22%0A%7C%20summarize%20by%20TimeGenerated%2C%20HostName%2C%20AzureImageSku%2C%20AzureResourceGroup%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AzureLocation%2C%20AzureSize%2C%20Cpus%2C%20DependencyAgentVersion%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PhysicalMemoryMB%2C%20OperatingSystemFamily%2C%20OperatingSystemFullName%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20VirtualMachineType%2C%20VirtualizationState%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tostring(Ipv4Addresses)%2C%20tostring(Ipv4DefaultGateways)%2C%20tostring(Ipv4SubnetMasks)%2C%20tostring(MacAddresses)%0A%2F%2F%20right%20Table%0A%7C%20join%20(%0A%20%20%20%20Heartbeat%0A%20%20%20%20%2F%2F%0A%20%20%20%20%2F%2F%20I%20consider%20a%20machine%20to%20be%20running%20if%20we%20have%20a%20positive%20heartbeat%20count%20in%20the%20past%20hour%20%0A%20%20%20%20%2F%2F%20This%20only%20tests%20the%20agent%20not%20the%20server%0A%20%20%20%20%2F%2F%0A%20%20%20%20%7C%20where%20TimeGenerated%20%26gt%3B%20ago(1h)%0A%20%20%20%20%7C%20summarize%20%20HeartbeatCount%20%3D%20count()%20by%20Computer%0A)%20on%20%24left.HostName%20%3D%3D%20%24right.Computer%20%20%20%2F%2F%20join%20on%20the%20HostName%2C%20by%20mapping%20that%20to%20the%20Computer%20name%20%0A%7C%20extend%20isRunning%20%3D%20iif(HeartbeatCount%20%26gt%3B%3D0%20%20%20%2C%22Running%22%2C%22Not%20found%22)%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA2VSXW%25252FaQBB8R%25252BI%25252FbKw8gGTFrdRXRyJEJUglrQLiNTrshbvG96G7PahRfnzXNoZS%25252FGKfd252dnayDCrcEqzEpsLhYL2YWu0ioR8OPuEg0SO8v2Gw0Rc4L%25252BEuhyRpSiFqLbw6ImxqWCmNMzToBWGZwosN9Co0pjA5Ro9zLXa4%25252FIinY8828za6dDiA66fF%25252FLCFIGXN6cqS%25252B6QwdTGk8IwOTYmmqCc7NLRGH1rgDdEvWQdViGqB2vp68ZTCT9coVGa3rAOh%25252Fi60qurb37GqOvU3lGvlKTKjKKQyuKodg07%25252F1LEVvCS24HYoYkc8dxjN3f7bpCw9hoBhnF4XnnErYkUzpjiI%25252Bqa8jBuDtBDh46rEai6Mw0GWgVc7ed7oJ%25252Fy2ysCo0%25252FSCwtMGBXXHLOvfMIfCmqBK9CBAdxNyE9gg%25252BGgMdwK1hQOCFHtkiLNBkeJP2VMyQTQE3IwkghOBQPKm4dxiJVUAa6oaCAOFFiaaJYKx1J4C%25252Bn0TvX%25252B19TG8Chk88k07%25252BirHPegSyMuQ01ZQ3gkbjZuoXuI9Zilw34T%25252FoQ8s5Dnct%25252B499LhOeWuh7Qa7pJvptHCusYYkz89uNYDzVdNQNhvAP8SZBRXeTk7moNR29J%25252FOx%25252FwLd0uTEyhJk1e2Zcu1Mhn%25252FBWaZTUmoAwAA%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Ee.g.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CDIV%3E%0A%3CTABLE%20cellspacing%3D%221%22%20cellpadding%3D%225%22%3E%0A%3CTBODY%3E%0A%3CTR%3E%0A%3CTH%3EHostName%3C%2FTH%3E%0A%3CTH%3EisRunning%3C%2FTH%3E%0A%3CTH%3EHeartbeatCount%3C%2FTH%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3Erancher-node-3%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3Egangams-kind-k8s-cluster-master%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3EInfraScaleVMs%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3Edemo2%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3EMarketingLinux1%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3Enode-4%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E30%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3Erancher-node-1%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3Erancher-node-2%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E60%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3CTR%3E%0A%3CTD%3EContosoASCAlert%3C%2FTD%3E%0A%3CTD%3ERunning%3C%2FTD%3E%0A%3CTD%3E59%3C%2FTD%3E%0A%3C%2FTR%3E%0A%3C%2FTBODY%3E%0A%3C%2FTABLE%3E%0A%3C%2FDIV%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20disk%20size%20you%20will%20need%20a%20counter%20-%20do%20you%20have%20any%20for%20disk%2C%20normally%20these%20are%20under%20the%20%3CSTRONG%3EPerf%3C%2FSTRONG%3E%20table%3F%3CBR%20%2F%3E%3CBR%20%2F%3EThere%20is%20an%20example%20query%20when%20you%20OPEN%20a%20new%20Tab.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-cpp%22%3E%3CCODE%3E%2F%2F%20Top%2010%20computers%20with%20the%20highest%20disk%20space%0A%2F%2F%20Show%20the%20top%2010%20computers%20with%20the%20highest%20available%20disk%20space%0APerf%0A%7C%20where%20CounterName%20%3D%3D%20%22Free%20Megabytes%22%20and%20InstanceName%20%3D%3D%20%22_Total%22%20%0A%7C%20summarize%20arg_max(TimeGenerated%2C%20*)%20by%20Computer%0A%7C%20top%2010%20by%20CounterValue%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1231845%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1231845%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239477%22%20target%3D%22_blank%22%3E%40Clive%20Watson%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eregarding%20VM%20state%20its%20seems%20difficult%20to%20get%20the%20state%20of%20VMs%20with%20output%20what%20we%20are%20getting%20using%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EVMComputer%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20TimeGenerated%20%26gt%3B%20ago(%3C%2FSPAN%3E%3CSPAN%3E1%3C%2FSPAN%3E%3CSPAN%3Ed)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20_ResourceId%20!%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%20%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20TimeGenerated%2C%20HostName%2C%20AzureImageSku%2C%20AzureResourceGroup%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EAzureLocation%2C%20AzureSize%2C%20Cpus%2C%20DependencyAgentVersion%2C%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EPhysicalMemoryMB%2C%20OperatingSystemFamily%2C%20OperatingSystemFullName%2C%20%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3EVirtualMachineType%2C%20VirtualizationState%2C%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3Etostring(Ipv4Addresses)%2C%20tostring(Ipv4DefaultGateways)%2C%20tostring(Ipv4SubnetMasks)%2C%20tostring(MacAddresses)%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3ELike%20I%20want%20to%20get%20VM%20status%20in%20front%20of%20the%20above%20query%20output%20as%20Running%20or%20Stopped%20(Deallocated)%3C%2FSPAN%3E%3C%2FDIV%3E%3C%2FDIV%3E%3CP%3Eor%20Stopped.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20not%20possible%2C%20can%20you%20help%20to%20integrate%20below%20query%20details%20for%20disk%20space%20with%26nbsp%3B%3CSPAN%3EVMComputer%20output%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%3E%3CDIV%3E%3CSPAN%3EPerf%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20TimeGenerated%20%26gt%3B%20now(-%3C%2FSPAN%3E%3CSPAN%3E10%3C%2FSPAN%3E%3CSPAN%3Emin)%20%3C%2FSPAN%3E%3CSPAN%3Eand%3C%2FSPAN%3E%3CSPAN%3E%20CounterName%20%3D%3D%20%3C%2FSPAN%3E%3CSPAN%3E%22%25%20Free%20Space%22%3C%2FSPAN%3E%20%3CSPAN%3Eand%3C%2FSPAN%3E%3CSPAN%3E%20InstanceName%20!%3C%2FSPAN%3E%3CSPAN%3Econtains%3C%2FSPAN%3E%20%3CSPAN%3E%22DPM%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Ewhere%3C%2FSPAN%3E%3CSPAN%3E%20strlen(InstanceName)%20%3D%3D%3C%2FSPAN%3E%3CSPAN%3E2%3C%2FSPAN%3E%20%3CSPAN%3Eand%3C%2FSPAN%3E%3CSPAN%3E%20InstanceName%20%3C%2FSPAN%3E%3CSPAN%3Econtains%3C%2FSPAN%3E%20%3CSPAN%3E%22%3A%22%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esummarize%3C%2FSPAN%3E%3CSPAN%3E%20FreeDiskSpace%20%3D%20(avg(CounterValue))%20%3C%2FSPAN%3E%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20bin(TimeGenerated%2C%20%3C%2FSPAN%3E%3CSPAN%3E1%3C%2FSPAN%3E%3CSPAN%3Eh)%2C%20Computer%2C%20InstanceName%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%3CSPAN%3E%7C%20%3C%2FSPAN%3E%3CSPAN%3Esort%3C%2FSPAN%3E%20%3CSPAN%3Eby%3C%2FSPAN%3E%3CSPAN%3E%20TimeGenerated%2C%20Computer%20desc%3B%3C%2FSPAN%3E%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3CDIV%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1232212%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1232212%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380509%22%20target%3D%22_blank%22%3E%40Rahul_Mahajan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELike%20this%3F%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA2WT3YrbMBCF7w15h2mgYINLuqVXhRTSDZsG6jbUIbdFkSe2Gmlk9LNBYR%25252B%25252BspPdxLWuLM3RN0cz49kMJB4cbNle4iTZFY9atd6hmSQvcGrQIAhL2qFqXUj%25252F%25252FEarveG4rrJOYL1SzIgzwj7AVihcIaFhDqscvmvrfjKFOSzO3uBasRrLo79uX0Ero32bTxIYrl7zQ3PmhKbrlTLmyeGx9TaHJbZIFRIPixrJ7dDYXjgCbZpgBWeyQKVNKL7l8KvtHAqqy2Djs56YEjKMj72UF%25252Fcj5E4Y5yOR8UYQbkMbRdczce4Nly6WYPwoFytiYoZ03T5%25252FXlSVQWvRZvkwsMQD89KtIuLEwihc%25252Bj2hK5g9DkLRzT3x1sXZDIyom7cOv8BfLQjSi7sNmsPl67Xbgy7CVyB9Sj88fFSCMmBURbKnCO5qA%25252FM5TN%25252FDk0GEsmUcp71iTdYx4thL3nFNjgmyMF1uiukwV%25252FQukdL7C1mEfhpjbpQvb4zb8HUOlsIeexMwh5Q91%25252BnV6I5Jj1nWDeheUPrfkD40d8XKBzknSQaa4P5%25252F0KZCMxp1uBGgQsuTf9RyQqRUAwAA%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%2F%2F%20left%20Table%0AVMComputer%0A%7C%20where%20isnotempty(_ResourceId)%0A%7C%20summarize%20by%20TimeGenerated%2C%20HostName%2C%20AzureImageSku%2C%20AzureResourceGroup%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20AzureLocation%2C%20AzureSize%2C%20Cpus%2C%20DependencyAgentVersion%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20PhysicalMemoryMB%2C%20OperatingSystemFamily%2C%20OperatingSystemFullName%2C%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20VirtualMachineType%2C%20VirtualizationState%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20tostring(Ipv4Addresses)%2C%20tostring(Ipv4DefaultGateways)%2C%20tostring(Ipv4SubnetMasks)%2C%20tostring(MacAddresses)%2C%20Computer%0A%2F%2F%20right%20Table%0A%7C%20join%20(%0A%20%20%20%20Perf%0A%20%20%20%20%7C%20where%20TimeGenerated%20%26gt%3B%20now(-10min)%20and%20CounterName%20%3D%3D%20%22%25%20Free%20Space%22%20and%20InstanceName%20!contains%20%22DPM%22%0A%20%20%20%20%7C%20where%20strlen(InstanceName)%20%3D%3D2%20and%20InstanceName%20contains%20%22%3A%22%0A%20%20%20%20%7C%20summarize%20FreeDiskSpace%20%3D%20(avg(CounterValue))%20by%20bin(TimeGenerated%2C%201h)%2C%20Computer%2C%20InstanceName%0A)%20on%20Computer%0A%7C%20order%20by%20TimeGenerated%20%2C%20Computer%20desc%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3Eor%20(with%20running%20info)%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1232333%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1232333%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380509%22%20target%3D%22_blank%22%3E%40Rahul_Mahajan%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CBR%20%2F%3EDepending%26nbsp%3Bon%20your%26nbsp%3Buse%20case%2C%20if%20you%20just%20wanted%20to%20visually%20see%20this%26nbsp%3Btype%20of%20data%26nbsp%3Ba%20Azure%20Monitor%20Workbook%20should%26nbsp%3Bhelp.%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20look%20for%20and%20open%20the%20file%20(RAW%20mode%20is%20best)%20at%20this%20link%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FCliveW-MSFT%2FKQLpublic%2Fblob%2Fmaster%2FKQL%2FWorkbooks%2FAzureVMwithDiskspace.workbook%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FCliveW-MSFT%2FKQLpublic%2Fblob%2Fmaster%2FKQL%2FWorkbooks%2FAzureVMwithDiskspace.workbook%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3Eyou%20just%20need%20to%20COPY%20all%20the%20file%20content%20(Ctrl%2BA%20then%20Ctrl%2BC)%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EInstallation%26nbsp%3B%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%5B%3CSTRONG%3ECopy%3C%2FSTRONG%3E%5D%20the%20workbook%20file%20content%20(these%20are%20JSON%20files)%2C%20open%20Azure%20Monitor%20Workbooks%20(from%20portal.azure.com)%20%E2%80%93%20open%20the%20%E2%80%9C%3CSTRONG%3Eempty%3C%2FSTRONG%3E%E2%80%9D%20Azure%20Monitor%20Workbook%2C%20in%20%E2%80%9C%3CSTRONG%3Eadvanced%20edit%3C%2FSTRONG%3E%E2%80%9D%20mode%20(press%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3E%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eicon%20for%20advanced%20edit%20).%20Please%20%5B%3CSTRONG%3Epaste%3C%2FSTRONG%3E%5D%20over%20any%20json%20that%20exists.%3C%2FLI%3E%0A%3CLI%20class%3D%22%22%3EThen%20Press%20%5B%3CSTRONG%3Eapply%3C%2FSTRONG%3E%5D%20then%20%5B%3CSTRONG%3EDone%20Editing%3C%2FSTRONG%3E%5D%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%3EThis%20should%20look%20like%26nbsp%3B%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CDIV%20id%3D%22tinyMceEditorClive%20Watson_0%22%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic1.jpg%22%20style%3D%22width%3A%20582px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F177376iDC98E62090B323D0%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic1.jpg%22%20alt%3D%22pic1.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EYou%20can%20use%20the%20Search%26nbsp%3Bbar%20(circled%26nbsp%3Bin%20red)%20to%20filter%20on%20state%2C%20like%20Succeeded%20or%20Deallocated%20etc...%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EWhen%20you%20highlight%20a%20Virtual%20Machine%2C%20click%20on%20a%20ROW%20(and%20if%20there%20is%20data)%20you%20get%20the%20VM%20Connection%26nbsp%3Binfo%20an%20or%20the%20Disk%20Space%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22pic2.jpg%22%20style%3D%22width%3A%20513px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F177377iACF4559C18F87884%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22pic2.jpg%22%20alt%3D%22pic2.jpg%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1232485%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1232485%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239477%22%20target%3D%22_blank%22%3E%40Clive%20Watson%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWill%20try%20it%20%3A)For%20now%2C%20I%20have%20changed%20the%20query%20like%20%3AVMComputer%7C%20where%20isnotempty(_ResourceId)%7C%20join%20kind%3D%20innerunique%20(Perf%7C%20where%20TimeGenerated%20%26gt%3B%20now(-10min)%20and%20CounterName%20%3D%3D%20%22%25%20Free%20Space%22%20and%20InstanceName%20!contains%20%22DPM%22%7C%20where%20strlen(InstanceName)%20%3D%3D2%20and%20InstanceName%20contains%20%22%3A%22%7C%20summarize%20FreeDiskSpace%20%3D%20(avg(CounterValue))%20by%20bin(TimeGenerated%2C%201h)%2C%20InstanceName%2CComputer)%20on%20Computer%7C%20summarize%20by%20TimeGenerated%2C%20Computer%2C%20AzureImageSku%2C%20AzureResourceGroup%2CAzureLocation%2C%20AzureSize%2C%20Cpus%2C%20DependencyAgentVersion%2CPhysicalMemoryMB%2C%20OperatingSystemFamily%2C%20OperatingSystemFullName%2CVirtualMachineType%2C%20VirtualizationState%2C%20tostring(Ipv4Addresses)%2C%20tostring(Ipv4DefaultGateways)%2C%20tostring(Ipv4SubnetMasks)%2C%20tostring(MacAddresses)%2C%20InstanceName%2C%20FreeDiskSpaceHere%20there%20are%20multiple%20records%20are%20showing%20as%20different%20drives%20for%20same%20server.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1232602%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1232602%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F380509%22%20target%3D%22_blank%22%3E%40Rahul_Mahajan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFor%20a%20single%20line%20output%20you%20can%20try%2C%20a%20query%20like%20this%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fms.portal.azure.com%23%4072f988bf-86f1-41af-91ab-2d7cd011db47%2Fblade%2FMicrosoft_Azure_Monitoring_Logs%2FDemoLogsBlade%2FresourceId%2F%252FDemo%2Fsource%2FLogsBlade.AnalyticsShareLinkToQuery%2Fq%2FH4sIAAAAAAAAA3WSTWvbQBCG7wb%25252Fh6mgIJU9hZ4COrgxMYaoNVXw1UykibyVdlfdjyQy%25252FfEdCaX2OlS33X3nmWdHuy%25252FujOqDJ7tc%25252FIHXI1kC6bTxpHo%25252FpIef5EywFW3rbAz8MlIDtFLXOUityQYtfwcCSJeLHdnnMwTuTNCM%25252FY6KIM8h%25252BQz3lgjKHitKAHUNW%25252B086oqmyKfKaI9SO0jWuyK5ADlvO9LpZTpj4s1HxhG5%25252BnaqdUEptPJEUO2xGw0BcrDsVKf40qSz3XSWiZtMgMKWDo78VSN4GqImAi4HRm%25252Beri3y0bjCGCQSuIUExKzDw8zA6Ih1VkbbHBS%25252BpY9S0YZ4yuipFvAlG2X%25252B1YiobUxYS9c%25252BSOdZ5j%25252F3YtIV%25252FsxdnYKlrcKGyjbMy%25252FeHsOEZ9mK5gItvCjwYvrM0es6XrMHMPjgBa%25252Bp5SqSrYdWQ9nuybgzGkN1xcLLCriBl7FB8E%25252FCjH9WkbsrB8Xu8RyW74eN26LppwjFuL60PTMPqKDU9Dj3bzHvyNImWnu8twBv%25252BXUxLt%25252F3L11VdW3KOXHZ1sKZnDJ3fcMkrDuNx3C4Kl%25252BFJky%25252FQtRGHXc785eIv9Mq343sDAAA%25253D%2Ftimespan%2FP1D%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EGo%20to%20Log%20Analytics%20and%20run%20query%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1237066%22%20slang%3D%22en-US%22%3ERe%3A%20VM%20details%20query%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1237066%22%20slang%3D%22en-US%22%3EPerfect%20%3A)%3C%2Fimg%3E%3CBR%20%2F%3E%3CBR%20%2F%3EThanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F239477%22%20target%3D%22_blank%22%3E%40Clive%20Watson%3C%2FA%3E%3C%2FLINGO-BODY%3E
Contributor

Hi Team,

 

Trying to query VM details using KQL but unable to include different thing in query.

 

VMComputer
| where _ResourceId != ""
| summarize by TimeGenerated, HostName, AzureImageSku, AzureResourceGroup, AzureLocation, AzureSize, Cpus, DependencyAgentVersion, PhysicalMemoryMB, OperatingSystemFamily, OperatingSystemFullName, VirtualMachineType, VirtualizationState
 
Unable to include IPaddress details in it which can be seen using :
 
| project Computer, Ipv4Addresses, Ipv4DefaultGateways, Ipv4SubnetMasks, MacAddresses
 
Also, it doesn't have a state of VM like Running or Stopped
 
Can someone help to include them in one query?
 
Thanks in advance.
9 Replies
best response confirmed by Rahul_Mahajan (Contributor)
Solution

@Rahul_Mahajan 

 

Those data types are arrays, so need to be strings at the end of a Summarize - I used tostring to allow this 

 

Go to Log Analytics and run query

 

VMComputer
| where _ResourceId != ""
| summarize by TimeGenerated, HostName, AzureImageSku, AzureResourceGroup,
               AzureLocation, AzureSize, Cpus, DependencyAgentVersion, 
               PhysicalMemoryMB, OperatingSystemFamily, OperatingSystemFullName, 
               VirtualMachineType, VirtualizationState,
               tostring(Ipv4Addresses), tostring(Ipv4DefaultGateways), tostring(Ipv4SubnetMasks), tostring(MacAddresses)

Thanks ton @Deleted

One more thing.. can you please help to get VM disk size and state added like stopped or running as I am not able to find any details in it for that.

 

or suggest any other query which will have all these details.

@Rahul_Mahajan 

 

For running state if you don't have it in any of your tables (its not a default for logging) then you have to create a test.  Here I'm joining the data to the Heartbeat Table as all Log Analytics computers will have this (you may wish to use another Table instead or in addition).  Its a basic test as a Server could be up but the agent not sending data.

 

// left Table
VMComputer
| where _ResourceId != ""
| summarize by TimeGenerated, HostName, AzureImageSku, AzureResourceGroup,
               AzureLocation, AzureSize, Cpus, DependencyAgentVersion, 
               PhysicalMemoryMB, OperatingSystemFamily, OperatingSystemFullName, 
               VirtualMachineType, VirtualizationState,
               tostring(Ipv4Addresses), tostring(Ipv4DefaultGateways), tostring(Ipv4SubnetMasks), tostring(MacAddresses)
// right Table
| join (
    Heartbeat
    //
    // I consider a machine to be running if we have a positive heartbeat count in the past hour 
    // This only tests the agent not the server
    //
    | where TimeGenerated > ago(1h)
    | summarize  HeartbeatCount = count() by Computer
) on $left.HostName == $right.Computer   // join on the HostName, by mapping that to the Computer name 
| extend isRunning = iif(HeartbeatCount >=0   ,"Running","Not found")

 

Go to Log Analytics and run query

 

e.g.

 

HostName isRunning HeartbeatCount
rancher-node-3 Running 60
gangams-kind-k8s-cluster-master Running 60
InfraScaleVMs Running 60
demo2 Running 60
MarketingLinux1 Running 60
node-4 Running 30
rancher-node-1 Running 60
rancher-node-2 Running 60
ContosoASCAlert Running 59

 

For disk size you will need a counter - do you have any for disk, normally these are under the Perf table?

There is an example query when you OPEN a new Tab.

// Top 10 computers with the highest disk space
// Show the top 10 computers with the highest available disk space
Perf
| where CounterName == "Free Megabytes" and InstanceName == "_Total" 
| summarize arg_max(TimeGenerated, *) by Computer
| top 10 by CounterValue






 

@CliveWatson 

 

regarding VM state its seems difficult to get the state of VMs with output what we are getting using 

 

VMComputer
| where TimeGenerated > ago(1d)
| where _ResourceId != ""
| summarize by TimeGenerated, HostName, AzureImageSku, AzureResourceGroup,
AzureLocation, AzureSize, Cpus, DependencyAgentVersion,
PhysicalMemoryMB, OperatingSystemFamily, OperatingSystemFullName,
VirtualMachineType, VirtualizationState,
tostring(Ipv4Addresses), tostring(Ipv4DefaultGateways), tostring(Ipv4SubnetMasks), tostring(MacAddresses)
 
Like I want to get VM status in front of the above query output as Running or Stopped (Deallocated)

or Stopped.

 

If not possible, can you help to integrate below query details for disk space with VMComputer output

 

Perf
| where TimeGenerated > now(-10min) and CounterName == "% Free Space" and InstanceName !contains "DPM"
| where strlen(InstanceName) ==2 and InstanceName contains ":"
| summarize FreeDiskSpace = (avg(CounterValue)) by bin(TimeGenerated, 1h), Computer, InstanceName
| sort by TimeGenerated, Computer desc;
 
 
 

@Rahul_Mahajan 

 

Like this? Go to Log Analytics and run query

// left Table
VMComputer
| where isnotempty(_ResourceId)
| summarize by TimeGenerated, HostName, AzureImageSku, AzureResourceGroup,
               AzureLocation, AzureSize, Cpus, DependencyAgentVersion, 
               PhysicalMemoryMB, OperatingSystemFamily, OperatingSystemFullName, 
               VirtualMachineType, VirtualizationState,
               tostring(Ipv4Addresses), tostring(Ipv4DefaultGateways), tostring(Ipv4SubnetMasks), tostring(MacAddresses), Computer
// right Table
| join (
    Perf
    | where TimeGenerated > now(-10min) and CounterName == "% Free Space" and InstanceName !contains "DPM"
    | where strlen(InstanceName) ==2 and InstanceName contains ":"
    | summarize FreeDiskSpace = (avg(CounterValue)) by bin(TimeGenerated, 1h), Computer, InstanceName
) on Computer
| order by TimeGenerated , Computer desc

 

or (with running info)

 

@Rahul_Mahajan 


Depending on your use case, if you just wanted to visually see this type of data a Azure Monitor Workbook should help.

 

Please look for and open the file (RAW mode is best) at this link: https://github.com/CliveW-MSFT/KQLpublic/blob/master/KQL/Workbooks/AzureVMwithDiskspace.workbook 

you just need to COPY all the file content (Ctrl+A then Ctrl+C)

 

Installation 

  1. [Copy] the workbook file content (these are JSON files), open Azure Monitor Workbooks (from portal.azure.com) – open the “empty” Azure Monitor Workbook, in “advanced edit” mode (press the </> icon for advanced edit ). Please [paste] over any json that exists.
  2. Then Press [apply] then [Done Editing]

This should look like 

 

pic1.jpg

You can use the Search bar (circled in red) to filter on state, like Succeeded or Deallocated etc...

 

When you highlight a Virtual Machine, click on a ROW (and if there is data) you get the VM Connection info an or the Disk Space 

 

pic2.jpg

 

@Clive Watson 

 

Will try it :)

For now, I have changed the query like :

VMComputer
| where isnotempty(_ResourceId)
| join kind= innerunique (
Perf
| where TimeGenerated > now(-10min) and CounterName == "% Free Space" and InstanceName !contains "DPM"
| where strlen(InstanceName) ==2 and InstanceName contains ":"
| summarize FreeDiskSpace = (avg(CounterValue)) by bin(TimeGenerated, 1h), InstanceName,Computer
) on Computer
| summarize by TimeGenerated, Computer, AzureImageSku, AzureResourceGroup,
AzureLocation, AzureSize, Cpus, DependencyAgentVersion,
PhysicalMemoryMB, OperatingSystemFamily, OperatingSystemFullName,
VirtualMachineType, VirtualizationState, tostring(Ipv4Addresses), tostring(Ipv4DefaultGateways), tostring(Ipv4SubnetMasks), tostring(MacAddresses), InstanceName, FreeDiskSpace

Here there are multiple records are showing as different drives for same server.

@Rahul_Mahajan 

 

For a single line output you can try, a query like this

Go to Log Analytics and run query

Perfect :)

Thanks @CliveWatson