Azure Monitor Metrics and Diagnostic Settings
30-second answer
Platform metrics are numbers every Azure resource sends to Azure Monitor about once a minute, with no setup, and Azure keeps them for 93 days. Resource logs (such as StorageRead or Key Vault AuditEvent) aren't kept at all until you create a diagnostic setting that sends them to a Log Analytics workspace, a storage account, Event Hubs or a partner solution. The activity log records control-plane actions (who created, changed or deleted what) for 90 days. A VM has no resource logs: its guest OS data comes through the Azure Monitor Agent and a data collection rule.
Simulate it » No Azure account neededExam objective: 5.1.1 Interpret metrics in Azure Monitor. 5.1.2 Configure log settings in Azure Monitor. (Skills measured as of April 17, 2026)
Simulations
Feel it before you read it. No account needed, nothing leaves this page.
Open the storage account. Platform metrics are already being collected, so start with <strong>Monitoring → Metrics</strong>.
👆 Click the glowing item in the portal to continue
Read the steps as text
- Open the storage account. Platform metrics are already being collected, so start with Monitoring → Metrics.
- Pick the Transactions metric with Sum. Apply splitting by ResponseType shows the spike is mostly AuthorizationError. Metrics are kept 93 days, but they don’t say who called.
- Open Diagnostic settings. Resource logs aren’t kept until you add one, and for storage you add it on the blob service.
- Name it, tick allLogs and Transaction, and choose Send to Log Analytics workspace. You could also archive to a storage account or stream to an event hub in the same setting.
- Now check who changed what. Search for Monitor.
- Type monitor in the search bar and pick Monitor under Services.
- The activity log covers control-plane actions for the whole subscription: here Ben listed the keys and deleted a VM. It keeps 90 days. Export Activity Logs opens a subscription diagnostic setting to keep it longer in the workspace.
🧪 Simulation for learning. Screens are simplified versions of the Azure portal; names, prices and IDs are examples. Nothing here touches real Azure.
🖱️ Drag to rotate · scroll or pinch to zoom
Resource logs need a diagnostic setting
Resource logs (StorageRead, AuditEvent, NSG events) are thrown away until a diagnostic setting routes them to a Log Analytics workspace, a storage account or Event Hubs. The activity log records who changed what in the subscription and keeps it 90 days.
🤔 What happens if…
Read this tour as text
- Platform metrics arrive on their own. Every Azure resource sends platform metrics (Percentage CPU, Transactions, Availability) to Azure Monitor about once a minute, with no agent and no setting. Metrics explorer charts them. Azure keeps them for 93 days.
- Resource logs need a diagnostic setting. Resource logs (StorageRead, AuditEvent, NSG events) are thrown away until a diagnostic setting routes them to a Log Analytics workspace, a storage account or Event Hubs. The activity log records who changed what in the subscription and keeps it 90 days.
- Ask the workspace with KQL. Logs land in tables in the workspace: AzureDiagnostics, StorageBlobLogs, AzureActivity, InsightsMetrics. KQL reads top to bottom through pipes:
wherefilters,summarize count() by bin(TimeGenerated, 5m)groups,render timechartdraws. - Alert rule fires into an action group. An alert rule watches a signal (a metric, a log query, the activity log) and fires when the condition holds. It hands the alert to an action group: email, SMS, push, voice, a webhook, a Logic App, a Function or an ITSM ticket.
- Alert processing rules. An alert processing rule acts on alerts that already fired. Suppress notifications during a maintenance window, or apply an action group to every alert in a scope. The alert still shows in Alerts; only the notifications change.
- Insights and Connection monitor. VM insights collects performance and a connection map through the Azure Monitor Agent and a data collection rule. Network Watcher Connection monitor runs TCP, HTTP or ICMP tests from an agent on the source VM and records failures and round-trip time.
- Back up to a vault on a schedule. A Recovery Services vault in the same region as the VM backs it up on a backup policy: when to run, how long to keep instant-restore snapshots and daily, weekly, monthly and yearly points. A Backup vault protects blobs, disks, PostgreSQL flexible servers and AKS.
- Restore, and soft delete. Restore files by mounting a recovery point, create a new VM, restore disks, or replace existing disks. Soft delete keeps deleted backup data for 14 days at no cost, so a mistake or an attacker can be undone.
- Site Recovery: replicate and fail over. Azure Site Recovery replicates a VM’s disks to another region, into a Recovery Services vault in the target region. A test failover builds a copy in an isolated network. A real failover is followed by commit and re-protect.
Contoso's storage account is getting odd 403 errors and nobody can say who's calling it. Read the platform metrics you get for free, find out what a diagnostic setting can and can't collect, route the blob logs to a Log Analytics workspace and ask KQL who failed.
🎓 Education-only simulation. Your lab is saved in this browser, so you can leave and continue later.
😟 THE PROBLEM
A storage account throws 403 errors and nobody knows who is calling it.
😊 THE SOLUTION
Read the metrics, then route the blob logs to a workspace with a diagnostic setting.
- Only a vague spike✓ Metrics split by response type
- Logs thrown away✓ A diagnostic setting on the blob service
- Who deleted the VM?✓ The activity log
Start with a question
Your car's dashboard shows speed and fuel all the time. So why doesn't it remember who borrowed it last Tuesday?
The dashboard gives you numbers the moment you start the engine: speed, fuel, temperature. Nobody had to switch that on. But if you want a record of every trip, who drove and where they went, you have to fit a trip recorder and decide where its data goes.
Azure works the same way. Platform metrics are the dashboard: CPU, transactions and availability arrive on their own. Resource logs are the trip recorder: they’re only kept once you add a diagnostic setting and choose where they go. And the activity log is the car’s service book: who changed the car itself.
Explain it like I’m 10
The technical explanation
Azure Monitor collects three kinds of data from Azure resources without you installing anything, but only one of them is kept by default.
| Data | What it is | Collected by default? | Kept | Where you see it |
|---|---|---|---|---|
| Platform metrics | Numbers sampled about once a minute (Percentage CPU, Transactions, Availability) | Yes | 93 days | Metrics explorer, metric alerts |
| Resource logs | Data-plane records from inside the resource (StorageRead, AuditEvent, NetworkSecurityGroupEvent) | No | Wherever you send them | Log Analytics, storage, Event Hubs |
| Activity log | Control-plane operations for the subscription: create, update, delete, role assignments, Service Health | Yes | 90 days | Monitor > Activity log, every resource’s Activity log blade |
Interpret metrics in Metrics explorer
Open any resource, then Monitoring > Metrics (or Monitor > Metrics and pick a scope). Each chart has:
- a metric namespace and metric, such as Account / Transactions on a storage account,
- an aggregation: Average, Min, Max, Sum or Count. Average CPU and Max CPU can tell very different stories,
- Add filter to keep one dimension value (only ResponseType = AuthorizationError),
- Apply splitting to draw one line per dimension value (one line per response type, per API name, per VM instance),
- a time range and time granularity. One chart can show up to 30 days, and you can pan back through the 93 days kept.
From the same chart you can Save to dashboard or select New alert rule. The CLI equivalent reads the same data:
az monitor metrics list \
--resource /subscriptions/<sub>/resourceGroups/rg-ops-mon/providers/Microsoft.Compute/virtualMachines/vm-web01 \
--metric "Percentage CPU" --interval PT1M --aggregation Average -o table
az monitor metrics list-definitions --resource <resource id> -o table # what metrics exist
Configure log settings with diagnostic settings
A diagnostic setting is a rule on one resource. It has a name, the log categories or category groups to send (allLogs or audit, which also pick up categories Microsoft adds later), optionally AllMetrics, and one or more destinations:
| Destination | Pick it when | Notes |
|---|---|---|
| Log Analytics workspace | You want to query with KQL, build workbooks or create log search alerts | Choose Azure diagnostics (one shared table) or Resource specific (one table per category, recommended where offered) |
| Storage account | You need a cheap archive for audits | Must be in the same region as the resource. Use lifecycle rules for retention |
| Event Hubs | You stream to a SIEM or a third-party tool | Needs a namespace and an authorization rule |
| Partner solution | You use an Azure Native ISV service such as Datadog or Elastic | Configured from the partner resource |
One setting can use several destinations at once, and a resource can have up to five diagnostic settings. Logs flow from the moment you save; nothing is backfilled.
Portal path: resource > Monitoring > Diagnostic settings > + Add diagnostic setting. For a storage account you first pick the blob, file, queue or table service, because that’s where StorageRead, StorageWrite and StorageDelete live. The account level only offers the Transaction metrics.
az monitor diagnostic-settings categories list \
--resource <storage id>/blobServices/default -o table
az monitor diagnostic-settings create --name diag-blob \
--resource <storage id>/blobServices/default \
--workspace law-contoso-ops \
--logs '[{"categoryGroup":"allLogs","enabled":true}]' \
--metrics '[{"category":"Transaction","enabled":true}]'
$log = New-AzDiagnosticSettingLogSettingsObject -CategoryGroup allLogs -Enabled $true
New-AzDiagnosticSetting -Name diag-blob -ResourceId "$storageId/blobServices/default" `
-WorkspaceId $workspaceId -Log $log
Virtual machines are different
A VM has no resource log categories. A diagnostic setting on a VM can only send platform metrics. Windows event logs, Syslog and guest performance counters come from the Azure Monitor Agent (AMA), and a data collection rule (DCR) says what to collect and which workspace to send it to. The old Log Analytics agent (MMA) and the Windows Azure Diagnostics extension are retired, so don’t pick them in a new design.
The activity log
The activity log is one per subscription and records control-plane events: someone created a VM, changed an NSG rule, assigned a role, listed storage keys, or Azure posted a Service Health event. It doesn’t record data-plane actions like reading a blob. Filter it by resource group, resource, operation, caller and time span in Monitor > Activity log, or from the CLI:
az monitor activity-log list -g rg-ops-mon --offset 1h -o table
az monitor activity-log list --caller ben@contoso.com --offset 7d
To keep it longer than 90 days or join it with other logs, select Export Activity Logs, which creates a subscription diagnostic setting (az monitor diagnostic-settings subscription create). In a workspace it lands in the AzureActivity table.
Architect level Resource-specific tables, costs and retention
When you send logs to a workspace, resource-specific mode writes each category to its own table (StorageBlobLogs, AzureBackup tables, AppServiceHTTPLogs). Queries are faster, columns are typed and you can set retention per table. The older Azure diagnostics mode puts everything into the wide AzureDiagnostics table. Some services only support one mode; Azure Backup reports need resource-specific.
Workspaces charge per GB ingested (around $2.30 per GB on pay-as-you-go for Analytics logs, illustrative) and include 31 days of retention. Interactive retention goes up to two years, and long-term retention up to 12 years at a lower price. For noisy, rarely queried data, look at the Basic or Auxiliary table plans, or archive to storage instead.
Real-world business scenario
Contoso Pharma (fictional)
- The problem
- A storage account holding batch records showed a spike in failed requests on the Transactions metric, and an auditor asked who had read the files in the last month. Nobody could answer: no diagnostic settings existed.
- What they used
- Metrics explorer with splitting by response type showed the spike was authorization errors. The admin team added a diagnostic setting on the blob service with allLogs, sending to a Log Analytics workspace for KQL and to a same-region storage account with a seven-year lifecycle rule. A subscription diagnostic setting exported the activity log to the same workspace.
- Why that choice
- Metrics told them something was wrong within minutes. Resource logs told them who and from where. The activity log covered every configuration change.
- The result
- The next audit request took one KQL query. The failures turned out to be an old SAS token in a partner script, which was rotated the same day.
When to use it and when not to
✓ Use it when…
- You need to see how a resource is behaving right now or over the last 93 days: use Metrics explorer.
- You need to know who accessed data inside a resource: add a diagnostic setting for its resource logs.
- You need to know who changed or deleted a resource: read the activity log, and export it for longer retention.
✕ Think twice when…
- Sending every log category from every resource to a workspace "just in case". Pick categories you will query, or archive to storage.
- Using a diagnostic setting for guest OS data on a VM. Use the Azure Monitor Agent and a data collection rule.
- Relying on the activity log for data-plane auditing such as blob reads.
↔ Alternatives to consider
- Azure Policy (DeployIfNotExists) to create diagnostic settings on every new resource automatically.
- VM insights to switch on the Azure Monitor Agent and a ready-made data collection rule.
- Storage account archive instead of a workspace for logs you keep only for compliance.
Test yourself with exercises
5 original practice questions in the AZ-104 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.
Interview preparation
Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.
Beginner What's the difference between a metric and a log in Azure Monitor?
Model answer
A metric is a number sampled over time, like CPU percentage every minute. It's cheap, fast and great for charts and threshold alerts. A log is a record with lots of fields, like "GetBlob on invoice-12.pdf from 203.0.113.50 returned 403". Logs answer who, what and why, and you query them with KQL in a Log Analytics workspace.
Intermediate A developer says the storage account's logs show nothing. What's your first check?
Model answer
Whether there's a diagnostic setting at all, and whether it's on the right level. Storage resource logs live on the blob, file, queue and table services, not on the account itself. So I'd open Diagnostic settings, pick the blob service, tick allLogs and send it to the workspace. Logs only start flowing from that moment; there's no backfill.
Experienced developer How would you keep the activity log for two years?
Model answer
The activity log itself keeps 90 days. I'd add a subscription-level diagnostic setting that sends the categories I need (Administrative, Security, Policy, ServiceHealth and so on) to a Log Analytics workspace and set that table's retention to two years, or archive it to a storage account if nobody needs to query it often.
Scenario The security team wants Key Vault access logs in their SIEM in real time and the auditors want seven years of copies. How do you do both?
Model answer
One diagnostic setting on the vault with AuditEvent, sending to Event Hubs for the SIEM and to a storage account with a lifecycle rule for the long-term copy. I could add the workspace in the same setting too. A resource can have up to five diagnostic settings, but one with several destinations is usually enough.
Quick revision
Key points
- Platform metrics are automatic and kept 93 days. Metrics explorer charts them with aggregation, filtering and splitting.
- Resource logs need a diagnostic setting. Destinations are a Log Analytics workspace, a storage account, Event Hubs or a partner solution.
- Storage logs are set on each service (blobServices/default and so on), not on the account.
- The activity log is subscription-wide, control plane only, and kept 90 days. Export it with a subscription diagnostic setting.
- VMs have no resource log categories. Use the Azure Monitor Agent with a data collection rule for guest OS data.
Important terminology
- Platform metrics
- Numeric values that Azure resources send to Azure Monitor automatically, about once a minute, kept for 93 days.
- Metrics explorer
- The Metrics blade where you chart a metric with an aggregation, filters and splitting.
- Resource logs
- Data-plane logs from inside a resource, such as blob reads or Key Vault secret gets. Not collected until a diagnostic setting routes them.
- Activity log
- The subscription-level log of control-plane operations (create, update, delete, role assignments), kept 90 days.
- Diagnostic setting
- A rule on a resource that sends chosen log categories and metrics to a Log Analytics workspace, storage account, event hub or partner solution.
- Category group
- A shortcut in a diagnostic setting, allLogs or audit, that picks up new log categories automatically.
- Resource-specific mode
- A diagnostic setting option that writes logs to one table per category instead of the shared AzureDiagnostics table.
- Azure Monitor Agent
- The agent that collects guest OS logs and performance counters from VMs according to data collection rules.
Common mistakes
- Expecting resource logs from before the diagnostic setting existed. Collection starts when you save it.
- Adding the diagnostic setting on the storage account and wondering why StorageRead never appears.
- Thinking the activity log shows data-plane actions like reading a blob. It doesn't.
Exam tips
- "Query the logs with KQL" = destination Log Analytics workspace. "Cheapest long-term archive" = storage account. "Stream to a third-party SIEM" = Event Hubs.
- "Who deleted the VM?" = activity log. "Who read the blob?" = resource logs through a diagnostic setting.
- The storage account used as a destination must be in the same region as the monitored resource.
Five quick revision questions
-
1.How long are platform metrics kept?Show
93 days.
-
2.How long does the activity log keep events?Show
90 days.
-
3.Name the four diagnostic setting destination types.Show
Log Analytics workspace, storage account, Event Hubs, partner solution.
-
4.What collects guest OS logs from a VM?Show
The Azure Monitor Agent with a data collection rule.
-
5.How many diagnostic settings can one resource have?Show
Up to five.
Official references
Finished this lesson? Tick it off. Your progress is saved in this browser.
Next up: Query Azure Monitor Logs with KQL
Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges.