How can I get an alert when a specifc Drive is under a preset amount using InsightsMetrics

Lebogang Mocoakae 20 Reputation points
2023-07-18T13:43:25.8866667+00:00

I am trying to get and alert like this one but using InsightsMetrics instead of Pref:

let setgbvalue = 200;//Set the disk space you want to check for.  Perf  | where TimeGenerated > ago(1h) | where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes" // exclude all others as we are checking for C: here  | where InstanceName != "D:"   | where InstanceName  != "_Total"  | where InstanceName != "HarddiskVolume1"  | extend FreeSpaceGB = CounterValue/1024 // converting the counter value to GB  | summarize FreeSpace = min(FreeSpaceGB) by Computer, InstanceName  | where FreeSpace < setgbvalue //setting condition to check if the value is less than our set value .

Kindly Assist, Thank you.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,037 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 21,251 Reputation points
    2023-07-19T08:03:18.2+00:00

    @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:

    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.


0 additional answers

Sort by: Most helpful