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

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

Accepted answer
  1. Timmy Malmgren 1,521 Reputation points
    2024-10-24T14:00:53.1466667+00:00

    Hi

    You should check out AMBA from Microsoft that already have this exact alert in its catalog (its even at your threshold with 10%) :)

    https://azure.github.io/azure-monitor-baseline-alerts/services/Compute/virtualMachines/#data-disk-free-space-percentage

    AMBA (Azure monitor baseline alerts) is a collection of Alerts from Microsoft, you can use it as a package or check out each individual resource/alerts per resource. They give you the option both to deploy with Azure policy, arm/biceps or deploy directly into the portal.

    You can also go through other resources in the catalog to se some of Microsoft's general recommendation (ofc these are just baselines that needs to be evaluated by you).

    Hope this is helpful and remember shared knowledge is the best knowledge 😊

    Best Regards,

    Timmy Malmgren


    If the Answer is helpful, please click "Accept Answer" and upvote it as it helps others to find what they are looking for faster!


0 additional answers

Sort by: Most helpful

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.