How to setup an Azure Alert to be triggered when our VM disks go below 10% free space

Ghulam Abbas 191 Reputation points
2024-10-02T13:46:41.2833333+00:00

Hi, we would like some assistance to setup an Azure alert with correct "Measurement" and "Alert logic" values. We are using this query that brings us the result of all our servers with their disks free space. We would like to setup an alert using this query that should triggered when any of the disks goes below 10% of Free space. We are not sure on the correct values to be used (Such as under Measurement; Measure, Aggregation type, Aggregation granularity and under Alert logic; Operator, Threshold Value, Frequency of evaluations etc):

InsightsMetrics
| where Name == 'FreeSpaceMB'
| summarize arg_max(TimeGenerated, *) by Tags, Computer
| extend Drive = tostring(parse_json(Tags)["vm.azm.ms/mountId"])
| extend Size = toreal(parse_json(Tags)["vm.azm.ms/diskSizeMB"])
| project
    TimeGenerated,
    Computer,
    Drive,
    bin(SizeGB = Size / 1024, 0.1),
    bin(FreeGB = Val / 1024, 1)
| join kind=inner (InsightsMetrics
    | where Name == "FreeSpacePercentage"
    | summarize arg_max(TimeGenerated, *) by Tags, Computer
    | extend Drive = tostring(parse_json(Tags)["vm.azm.ms/mountId"])
    | project TimeGenerated, Computer, Drive, bin(FreePercent = Val, 1.1))
    on Computer, Drive
| project TimeGenerated, Computer, Drive, SizeGB, FreeGB, FreePercent
| order by Computer asc


We are currently using these values but not getting the correct result s wondering what values do we need to select here while setting up this alert:

alert-diskspace

Many thanks

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,247 questions
Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,864 questions
Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
875 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.