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

Lebogang 20 Reputation points

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.
2,656 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnuragSingh-MSFT 18,581 Reputation points

    @Lebogang , 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;
    | where Origin == "" 
      and Namespace == "LogicalDisk" 
      and Name == "FreeSpaceMB"
    | extend Disk = tostring(todynamic(Tags)[""])
    | 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