Here are two ways to create an Azure Metric Alert on the LogicalDisk\FreeSpacePercentage metric so that it fires whenever any disk on the target VM(s) falls below 10% free space:
- Azure CLI
- ARM-template (or Bicep)
1) Azure CLI
# Variables
RG="myResourceGroup"
VM="/subscriptions/0000-0000-0000-0000/resourceGroups/$RG/providers/Microsoft.Compute/virtualMachines/myVM"
AG="/subscriptions/0000-0000-0000-0000/resourceGroups/$RG/providers/microsoft.insights/actionGroups/myActionGroup"
# Create the metric alert
az monitor metrics alert create \
--name LowDiskFreePct \
--resource-group $RG \
--scopes $VM \
--description "Alert when any disk FreeSpacePercentage < 10%" \
--condition "min LogicalDisk\\FreeSpacePercentage < 10" \
--window-size 5m \
--evaluation-frequency 1m \
--action-group $AG
Explanation of key flags:
--scopes → the VM(s) you want to monitor
--condition "min LogicalDisk\\FreeSpacePercentage < 10"
• min aggregation ensures we look at the smallest free-space % across all disks
--window-size & --evaluation-frequency → how often & over what period to evaluate
--action-group → where to route the alert (email, webhook, etc.)
2) ARM Template (JSON)
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"alertName": {
"type": "string",
"defaultValue": "LowDiskFreePct"
},
"vmResourceId": {
"type": "string",
"metadata": {
"description": "Full resource ID of the VM to monitor"
}
},
"actionGroupId": {
"type": "string",
"metadata": {
"description": "Resource ID of the Action Group to invoke"
}
}
},
"resources": [
{
"type": "Microsoft.Insights/metricAlerts",
"apiVersion": "2018-03-01",
"name": "[parameters('alertName')]",
"location": "global",
"properties": {
"description": "Fires when any disk free‐space% < 10",
"severity": 2,
"enabled": true,
"scopes": [
"[parameters('vmResourceId')]"
],
"evaluationFrequency": "PT1M",
"windowSize": "PT5M",
"criteria": {
"odata.type": "Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria",
"allOf": [
{
"name": "LowDiskFreePercentage",
"metricName": "LogicalDisk\\FreeSpacePercentage",
"metricNamespace": "microsoft.compute/virtualmachines",
"operator": "LessThan",
"threshold": 10,
"timeAggregation": "Minimum"
}
]
},
"autoMitigate": false,
"actions": [
{
"actionGroupId": "[parameters('actionGroupId')]"
}
]
}
}
]
}
How it works:
- We target the VM via its full resource‐ID in
scopes.
- We use
timeAggregation: Minimum so that if any disk instance reports < 10% free, the alert fires.
- You can bump
severity (0–4), change frequency/window, or add dimensions (e.g. filter a specific drive letter) if desired.
Feel free to adapt this to Bicep, PowerShell, or dynamic‐threshold criteria as your scenario requires! 🚀