When to use it
An alert fired, or someone says "it's slow", and you want numbers without clicking through Metrics Explorer. Platform metrics are collected automatically for most Azure resources. You don't need an agent or a Log Analytics workspace, and they're available within a few minutes. az monitor metrics list reads them straight from the CLI, which means you can script the checks and paste the output into the incident channel.
You need Monitoring Reader (or Reader) on the resource.
The core pattern
Every command needs the resource ID:
VM_ID=$(az vm show -g rg-app-prod -n vm-app-01 --query id -o tsv)
az monitor metrics list \
--resource "$VM_ID" \
--metrics "Percentage CPU" \
--aggregation Average Maximum \
--interval 5m \
--start-time 2026-11-24T06:00:00Z \
--end-time 2026-11-24T09:00:00Z \
-o table
| Parameter | What it does | Notes |
|---|---|---|
--metrics | One or more metric names, separated by spaces | Names are case-sensitive and often include spaces; quote them |
--aggregation | Average, Count, Maximum, Minimum, Total, None | Ask for Maximum as well as Average, because averages hide spikes |
--interval | Time grain, for example 1m, 5m, 1h | Default is 1m; not every metric supports every grain |
--start-time / --end-time | Time window in UTC (ISO 8601) | With no times given, you get the last hour |
--dimension | Split the results by a dimension | For example ApiName or ResponseType |
--filter | Filter on dimension values | "ResponseType eq '*'" splits by every value |
--namespace | Metric namespace | Needed for sub-resources such as storage blob services |
Tip
In PowerShell, build the start time like this:
(Get-Date).ToUniversalTime().AddHours(-3).ToString("yyyy-MM-ddTHH:mm:ssZ"). In Bash:date -u -d '-3 hours' +%Y-%m-%dT%H:%M:%SZ.
Find the right metric name
Don't guess names. List what the resource actually exposes:
az monitor metrics list-definitions --resource "$VM_ID" \
--query "[].{name:name.value, unit:unit, aggs:supportedAggregationTypes, dims:dimensions[].value}" -o table
For a storage account, the blob, file, queue and table services have their own namespaces:
SA_ID=$(az storage account show -g rg-data -n stproddata01 --query id -o tsv)
az monitor metrics list-definitions --resource "$SA_ID/blobServices/default" -o table
Metric names and dimensions change from time to time. If a name below isn't in your list-definitions output, use the name the output shows.
Get just the numbers
The default JSON output is deeply nested. Use JMESPath to pull out timestamps and values:
az monitor metrics list --resource "$VM_ID" --metrics "Percentage CPU" \
--aggregation Maximum --interval 5m \
--query "value[0].timeseries[0].data[].{time:timeStamp, max:maximum}" -o table
To find the single highest point in a window:
az monitor metrics list --resource "$VM_ID" --metrics "Percentage CPU" \
--aggregation Maximum --interval 1m \
--query "max_by(value[0].timeseries[0].data[?maximum!=null], &maximum)"
Virtual machines and disks
| Question | Metric | Aggregation |
|---|---|---|
| Is the CPU pegged? | Percentage CPU | Average, Maximum |
| Is memory low? | Available Memory Bytes | Minimum |
| Is the OS disk throttled? | OS Disk IOPS Consumed Percentage, OS Disk Bandwidth Consumed Percentage | Maximum |
| Is a data disk throttled? | Data Disk IOPS Consumed Percentage, Data Disk Bandwidth Consumed Percentage | Maximum (split by LUN) |
| Is the VM-level cap hit? | VM Cached IOPS Consumed Percentage, VM Uncached IOPS Consumed Percentage | Maximum |
| Is the CPU credit balance gone (B-series)? | CPU Credits Remaining | Minimum |
| Network volume | Network In Total, Network Out Total | Total |
az monitor metrics list --resource "$VM_ID" \
--metrics "Data Disk IOPS Consumed Percentage" \
--aggregation Maximum --interval 5m --filter "LUN eq '*'" -o table
If a disk sits at or near 100% consumed, it's being throttled at the disk or VM limit, and the guest sees high latency. Fix it by changing the disk tier or the VM size, not anything inside the OS.
Storage accounts
# Errors by response type (throttling shows as ServerBusyError or ClientThrottlingError)
az monitor metrics list --resource "$SA_ID" --metrics Transactions \
--aggregation Total --interval 5m --filter "ResponseType eq '*'" -o table
# Server vs end-to-end latency, split by operation
az monitor metrics list --resource "$SA_ID" \
--metrics SuccessE2ELatency SuccessServerLatency \
--aggregation Average --interval 5m --dimension ApiName -o table
| Pattern | Likely cause |
|---|---|
High SuccessE2ELatency, low SuccessServerLatency | The client or network is slow, not storage |
| Both latencies high | Storage is busy, or the requests are large |
Availability drops with ServerBusyError transactions | Account or partition limits hit |
AuthorizationError transactions | Bad key, SAS, RBAC or firewall rule |
Azure SQL Database
DB_ID=$(az sql db show -g rg-sql -s sql-prod-01 -n appdb --query id -o tsv)
az monitor metrics list --resource "$DB_ID" \
--metrics cpu_percent log_write_percent storage_percent workers_percent \
--aggregation Maximum --interval 5m -o table
| Metric | What to look for |
|---|---|
cpu_percent / dtu_consumption_percent | Sustained values near 100% mean you're hitting the compute limit |
log_write_percent | Near 100% means log throughput is throttling writes |
workers_percent | Near 100% leads to "resource limit reached" errors |
storage_percent | Approaching max size; inserts will start to fail |
connection_failed, blocked_by_firewall | Use Total; tells login problems apart from firewall blocks |
deadlock | Use Total; a jump after a deployment points at new code |
DTU metrics exist only on DTU-based databases. vCore databases report cpu_percent instead.
App Service
The plan holds the compute metrics and the app holds the HTTP metrics:
PLAN_ID=$(az appservice plan show -g rg-web -n asp-prod --query id -o tsv)
APP_ID=$(az webapp show -g rg-web -n app-prod-web --query id -o tsv)
az monitor metrics list --resource "$PLAN_ID" --metrics CpuPercentage MemoryPercentage \
--aggregation Maximum --interval 5m --filter "Instance eq '*'" -o table
az monitor metrics list --resource "$APP_ID" --metrics Requests Http5xx HttpResponseTime \
--aggregation Total Average --interval 5m -o table
If one instance is hot while the others are idle, the problem is that instance (or a sticky session), and adding more instances won't fix it.
Load Balancer and Application Gateway
| Resource | Metric | Meaning |
|---|---|---|
| Standard Load Balancer | VipAvailability | Data path health of the frontend |
| Standard Load Balancer | DipAvailability | Health probe status; split by BackendIPAddress |
| Standard Load Balancer | UsedSnatPorts, AllocatedSnatPorts | Outbound SNAT pressure |
| Application Gateway | UnhealthyHostCount | Backends failing probes; split by BackendSettingsPool |
| Application Gateway | FailedRequests, ResponseStatus | 5xx returned to clients |
LB_ID=$(az network lb show -g rg-net -n lb-app-prod --query id -o tsv)
az monitor metrics list --resource "$LB_ID" --metrics DipAvailability \
--aggregation Average --interval 1m --filter "BackendIPAddress eq '*'" -o table
Turn a check into an alert
When you find a metric that would have caught the problem, make it an alert:
az monitor metrics alert create -g rg-app-prod -n "vm-app-01 data disk throttled" \
--scopes "$VM_ID" \
--condition "max Data Disk IOPS Consumed Percentage > 95" \
--window-size 15m --evaluation-frequency 5m --severity 2 \
--action "/subscriptions/<sub>/resourceGroups/rg-ops/providers/microsoft.insights/actionGroups/ag-oncall"
Tip
Run
az monitor metrics alert create --helpto see the condition syntax for your CLI version, including how to add dimension filters (where LUN includes 0). Before you create the alert, use the same metric withmetrics listto check the threshold against last week's data.
Common errors
| Error | Cause | Fix |
|---|---|---|
Failed to find metric configuration for provider | Wrong metric name or namespace | Run list-definitions and copy the exact name |
Empty data or all null values | Wrong aggregation, or the resource was idle | Try Total or Count, or widen the window |
Invalid time grain | Interval not supported for that metric | Use 1m, 5m, 15m, 30m, 1h or a grain the metric supports |
AuthorizationFailed | No read access to the resource | Grant Monitoring Reader at the resource or resource group |
Prevent it next time
- Keep a script in your runbook repo with the resource IDs and
metrics listcommands for each critical service, so the first five minutes of an incident are a single command. - Platform metrics are kept for a limited time (check the current retention). If you need longer history, send metrics to Log Analytics with a diagnostic setting and query the
AzureMetricstable. - Always ask for
MaximumalongsideAverage. One-minute spikes are what users notice and what averages hide.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get