@Lebogang Mocoakae , Thank you for posting this question.
I understand that you are trying to translate the query in the question to fit with InsightsMetrics
with similar result. For details and help regarding it, you may refer the links below:
- Log query alert rules (Sample queries)
- VM Insights Performance record (to get an idea of how the information is stored for VM Insights)
Here is a converted query, to only look for C: drives free space available and return the Computers and freeSpace details:
let setgbvalue = 200;
InsightsMetrics
| where Origin == "vm.azm.ms"
and Namespace == "LogicalDisk"
and Name == "FreeSpaceMB"
| extend Disk = tostring(todynamic(Tags)["vm.azm.ms/mountId"])
| where Disk == 'C:' //As free space for only C: drive is required
| summarize FreeSpaceMB = avg(Val) by bin(TimeGenerated, 15m), Computer, Disk
| extend FreeSpaceGB = FreeSpaceMB/1024
| project-away FreeSpaceMB
| where FreeSpaceGB < setgbvalue
| project Computer, Disk, FreeSpaceGB
Hope this helps.
If the answer did not help, please add more context/follow-up question for it, and we will help you out. Else, if the answer helped, please click Accept answer so that it can help others in the community looking for help on similar topics.