Azure Monitor: Metrics, Logs, Diagnostic Settings & Alerts (AZ-104)
Azure Monitor is the Azure platform service that collects, analyzes and acts on telemetry from every resource in a subscription, and nearly every monitoring task starts with one distinction: metrics versus logs. Metrics are numeric, time-series values collected automatically in near real time, such as a virtual machine's CPU percentage each minute, and you interpret them in metrics explorer. Logs are structured records you query with Kusto Query Language (KQL) in a Log Analytics workspace. This lesson covers how to read metrics (aggregations, filtering versus splitting, namespaces), what the activity log records, how diagnostic settings route resource logs and metrics, how to query logs with KQL, how to build metric, log search and activity log alerts with action groups and alert processing rules, how Insights monitors VMs, storage and networks, and how Network Watcher and Connection monitor diagnose network paths. Backup and recovery are covered in a separate lesson.
On this page9 sections
- Azure Monitor and its two data types
- Metrics: numeric near-real-time data in Metrics Explorer
- Logs, Log Analytics, and KQL
- The activity log: who did what to your resources
- Diagnostic settings: where your logs and metrics go
- Alert rules: signal types, thresholds, and dimensions
- Action groups and alert processing rules
- Monitoring VMs, storage, and networks with Insights
- Network Watcher and Connection Monitor
- Distinguish metrics, the activity log, resource logs and guest data, and know which are collected without configuration
- Interpret metrics in metrics explorer by choosing the right aggregation and using filtering, splitting and namespaces
- Configure diagnostic settings, including destinations, category groups, storage sub-resources and Azure Policy at scale
- Query logs with KQL for trends and missing machines, and manage workspace retention
- Choose metric, log search or activity log alert rules, with static or dynamic thresholds and dimensions
- Use action groups and alert processing rules to notify, automate, route or suppress alerts
- Monitor VMs, storage accounts and networks with Insights and the Azure Monitor Agent
- Pick the right Network Watcher tool and Connection monitor for a network problem
Azure Monitor and its two data types
Azure Monitor is the single Azure service that collects telemetry from Azure resources, the platform itself, guest operating systems and applications, then lets you chart it, query it, alert on it and automate responses. Everything it collects is one of two data types, and most monitoring questions turn on picking the right one.
Metrics are lightweight numeric values captured at regular intervals, such as a percentage, a count or a number of bytes, stored in a time-series database built for fast charting. Platform metrics are collected automatically, with no agent and no configuration, and arrive in near real time. Logs are richer, structured records of discrete events, stored in a Log Analytics workspace and queried with Kusto Query Language (KQL). Metrics answer "how much, how fast, right now"; logs answer "what happened, when and why".
| Aspect | Metrics | Logs |
|---|---|---|
| Data shape | Numeric time-series values | Structured event and record data |
| Freshness | Near real time | Short ingestion delay |
| Explored with | Metrics explorer | Log Analytics (KQL queries) |
| Stored in | Azure Monitor Metrics (platform metrics kept 93 days) | Log Analytics workspace (retention you configure) |
| Collected by default? | Yes, for platform metrics | Only the activity log; resource logs and guest logs need configuration |
| Best for | Live charts, fast alerts | Troubleshooting, correlation, auditing, long history |
Platform logs come in three layers that are easy to confuse: the activity log (control-plane operations on resources, collected automatically), resource logs (what happens inside a resource, the data plane, collected only through a diagnostic setting) and Microsoft Entra logs (sign-ins and directory changes, part of Microsoft Entra ID rather than a subscription). The next sections cover each.
Metrics: numeric near-real-time data in Metrics Explorer
Metrics explorer is where you interpret metrics: you pick a scope (a resource), a metric namespace, a metric, an aggregation and a time granularity, and Azure draws the chart. Platform metrics such as Percentage CPU for a VM or Transactions for a storage account exist from the moment the resource is created.
The aggregation decides what the chart can show. Each point on the chart summarizes the raw samples inside one time grain:
- Avg shows the typical level, but smooths away short peaks and averages one hot instance with several idle ones.
- Max (and Min) expose spikes and troughs that Avg hides; use Max when you are hunting for a saturated resource.
- Sum adds the values in each grain, so it gives totals such as bytes sent or requests served per hour.
- Count is the number of samples (measurements) taken in the grain, not the total of their values.
Filtering and splitting both use dimensions, but they do opposite things. A dimension is a name-value pair attached to a metric, such as ApiName or ResponseType on storage transactions, or the instance name on a scale set.
| Filter | Split (apply splitting) | |
|---|---|---|
| What it does | Restricts which dimension values are counted, still drawing one line | Draws a separate line (series) for every dimension value |
| Typical use | Chart only geo-secondary reads (one GeoType value), or only requests using one Authentication type | Compare operations or response types side by side, or find which scale set instance is at 100% |
For a scale set whose average CPU looks healthy while users complain, switch to Max and split by instance: one pinned instance then stands out as its own line.
Namespaces and retention. Platform (host) metrics live in the resource's standard namespace. Guest operating system counters that the Azure Monitor Agent sends to Azure Monitor Metrics through a data collection rule appear under a separate guest metrics namespace (for example azure.vm.windows.guestmetrics), so you must switch namespace to find them. Platform metrics are kept for a fixed 93 days, and one metrics explorer chart can span at most 30 days. For longer history, or to query metrics with KQL alongside other data, export them with a diagnostic setting to a Log Analytics workspace (they land in the AzureMetrics table) and set the retention there.
Logs, Log Analytics, and KQL
Azure Monitor Logs stores structured records in a Log Analytics workspace, the container you query to investigate behaviour across many resources at once. Each table holds rows with many columns: AzureActivity for the activity log, Event for Windows event logs, Heartbeat for agent check-ins, AzureDiagnostics or resource-specific tables for resource logs, AzureMetrics for exported metrics.
You query that data in Log Analytics with KQL, a read-only language where a query starts with a table and pipes it through operators: where to filter rows (for example where EventLevelName == "Error" to keep only error events, or contains to find text in a message), summarize to aggregate, project to choose columns, sort to order and render to chart. Two patterns come up repeatedly:
- A trend over time:
summarize count() by bin(TimeGenerated, 1h)groups rows into hourly buckets, ready to render as a time chart. - Machines that stopped reporting: a machine that sends nothing produces no rows, and KQL never invents a zero for a group that has no rows. So a query that counts recent records per computer and looks for a count of zero returns nothing. Instead, look back over a longer period, use
summarizewithmax()(orarg_max()) to get each computer's most recent record time, and then keep the computers whose latest record is older than your silence threshold, for example an hour.
Retention is set per workspace and per table. Interactive (analytics) retention defaults to 30 days (the AzureActivity table keeps 90 days by default) and can be raised to two years; ordinary KQL queries reach that period. Beyond it, long-term (total) retention keeps data for up to 12 years at lower cost, but you reach it with a search job or by restoring the data, not with a normal query. Tables on the Basic plan cost less to ingest in exchange for limited query features. The workspace is also the boundary for access control and pricing.
The activity log: who did what to your resources
The activity log is the subscription-level record of control-plane operations, every create, update, delete or action call made through Azure Resource Manager, together with the caller, the time and the status. It is collected automatically for every subscription with no setup and kept for 90 days.
- Recorded: creating or deleting a VM, editing an NSG rule, assigning a role, regenerating or listing storage account keys, starting or stopping resources.
- Not recorded: data-plane activity such as reading a blob or getting a key vault secret (those are resource logs, which need a diagnostic setting), and user sign-ins (those are Microsoft Entra sign-in logs).
To keep activity log entries longer than 90 days or query them with KQL, create a diagnostic setting on the activity log itself (configured at subscription level, separately from any resource's settings) and send it to a Log Analytics workspace, where it lands in AzureActivity and retention can be extended; a storage account or event hub works for archive or streaming. The activity log is also the signal for activity log alerts, described below.
Diagnostic settings: where your logs and metrics go
A diagnostic setting is the configuration that sends a resource's resource logs and platform metrics somewhere you can keep or query them. Without one, resource logs are not collected at all. You choose the log categories (or a category group) and whether to include metrics, then the destinations.
| Destination | Use it to |
|---|---|
| Log Analytics workspace | Query with KQL, build log search alerts, correlate across resources; can also retain for years, but costs more than storage for data you rarely read |
| Storage account | Archive cheaply for audit retention when you rarely query |
| Event hub | Stream to a third-party SIEM or external tool |
| Partner solution | Send to an Azure Native ISV monitoring service integrated with Azure |
Structure rules:
- One setting can send to several destinations, but holds at most one destination of each type. Sending the same logs to two workspaces therefore needs two settings; a resource can have up to five.
- The category groups
allLogs(every category) andaudit(the audit-relevant subset) are maintained by Microsoft, so categories added later are collected automatically. Individually ticked categories stay exactly as ticked. - Settings are per resource and are not inherited from a resource group or subscription. To cover many resources, including ones created later, assign an Azure Policy with the
DeployIfNotExistseffect (built-in definitions exist per resource type) and run a remediation task to apply it to resources that already exist. - Storage accounts are a special case: resource logs are configured on each service sub-resource (blob, file, queue, table) with the categories
StorageRead,StorageWriteandStorageDelete; a setting on the account itself only exports metrics. - The activity log has its own subscription-level diagnostic setting, covered in the previous section.
Alert rules: signal types, thresholds, and dimensions
An alert rule watches one signal on a scope and fires when its condition is met. Each rule sets the condition, how often it is evaluated, a severity from Sev0 (critical) to Sev4 (verbose) and the action groups to call. The signal decides the rule type:
| Rule type | Signal | Needs a workspace? | Cost |
|---|---|---|---|
| Metric alert | A platform or custom metric | No | Billed per monitored time series |
| Log search alert | The result of a KQL query run on a schedule | Yes (or Application Insights) | Billed per rule, by evaluation frequency (and per monitored time series when it splits by dimensions) |
| Activity log alert | An activity log event, including Service Health and Resource Health | No | Free |
Service Health versus Resource Health: a Service Health alert reports Azure platform issues, planned maintenance and advisories affecting a service in a region you use; a Resource Health alert reports when one of your resources becomes unavailable or degraded.
Static versus dynamic thresholds. A static threshold is a fixed value you choose (CPU above 90%). A dynamic threshold lets machine learning learn the metric's normal pattern, including hourly, daily and weekly seasonality, and fires when the value leaves that band, above, below or either. You tune it with sensitivity (High fires on smaller deviations, Low only on large ones). It needs at least three days and 30 samples of history to start, and about three weeks to learn weekly seasonality. Persistence is a separate setting: the number of violations required within a number of evaluation periods (for example 4 of 4 five-minute periods = 20 minutes), which is how you ignore a single brief dip.
Dimensions in metric alerts. As in metrics explorer, you can filter a dimension to restrict what is counted (for example only the Authentication values you care about, so other traffic never reaches the threshold) or split by a dimension so each value (for example each scale set instance, or each storage GeoType) is evaluated as its own time series and fires its own alert naming that value. Filtering changes which data feeds one series; splitting changes how many series are watched. Choosing all current and future values makes the rule cover values that appear later without editing it.
Action groups and alert processing rules
An action group is a reusable list of who is notified and what runs when an alert fires: notifications (email, SMS, Azure mobile app push, voice) and actions (automation runbook, Azure Function, Logic App, webhook, secure webhook, ITSM, Event Hubs). Alert rules do not hold recipients themselves; they reference one or more action groups, and one action group can serve many rules. Turning on the common alert schema for an action gives one consistent payload format whether the alert came from a metric, log search or activity log rule, so a single Logic App or webhook can parse them all.
An alert processing rule changes what happens to fired alerts without editing the alert rules. It has a scope (subscription, resource group or resources), optional filters (severity, alert rule, monitor service, resource type and more; several filters must all match), one action and an optional schedule:
- Suppression stops action groups being called (for example during patching). Rules keep evaluating and alerts are still recorded, so nothing is lost; only notifications and actions are muted.
- Apply action groups adds an action group to every matching alert, so one rule can route alerts from many rules to a team.
- The schedule is always on, a one-time window, or recurring (daily or weekly), such as every weekday from 01:00 to 02:00 for a nightly backup job.
Processing rules cannot define recipients or actions of their own (they only suppress or apply existing action groups), do not change the alert payload and do not apply to Service Health alerts. Because filters narrow which alerts a rule touches, a suppression rule with a severity filter mutes only the severities it matches; alerts of any other severity keep calling their action groups as normal.
Monitoring VMs, storage, and networks with Insights
Insights are curated Azure Monitor experiences that pre-build the charts, queries and workbooks for one resource type, so you start from a finished view rather than a blank chart.
Virtual machines. Host platform metrics need no agent: CPU, network in/out, disk read/write bytes and operations, and now available memory (Available Memory Bytes and Available Memory Percentage). Anything only the guest operating system can see, such as free space per logical disk, page file usage, per-process counters, Windows event logs and Linux syslog, requires the Azure Monitor Agent plus a data collection rule (DCR) that says what to collect and where to send it (a Log Analytics workspace, Azure Monitor Metrics or both). The legacy Log Analytics agent was retired in August 2024; the Azure Monitor Agent is now the only supported agent for collecting guest logs and performance data. VM insights uses it to add guest performance charts, and its optional Map of processes and dependencies additionally needs the Dependency agent. Boot diagnostics is different again: it captures the serial log and a screenshot to troubleshoot a VM that will not start.
Storage accounts. Storage insights is built on aggregated platform metrics: capacity, transactions, availability, latency and throttling, across accounts. Compare two latency metrics: Success Server Latency is the time Azure Storage spent processing a request, while Success E2E Latency also includes the time to read the request from and send the response to the client. High end-to-end latency with low server latency points to the network or the client, not the storage service. Insights cannot show who made an individual request; for caller IP, authentication type or object URL per request you need storage resource logs sent through a diagnostic setting.
Networks. Network insights needs no setup: it shows the health and key metrics of network resources (virtual networks, load balancers, gateways, application gateways, public IPs and more) across subscriptions in one view, with a topology view of how they connect, and links to Network Watcher tools for diagnosis.
Network Watcher and Connection Monitor
Azure Network Watcher is the regional toolkit for diagnosing network paths in and between virtual networks. Each tool answers a different question:
| Tool | Answers |
|---|---|
| IP flow verify | Would this 5-tuple (protocol, local/remote IP and port, direction) be allowed or denied by NSG rules, and by which rule name |
| NSG diagnostics | The same allow/deny decision, showing each NSG and rule evaluated along the path |
| Next hop | Which route a VM uses for a destination: next hop type, IP and the route table that supplied it |
| Connection troubleshoot | A one-time test from a VM to an endpoint: reachable or not, hop by hop, with latency and the reason for a failure |
| Packet capture | The actual packets on a VM or scale set, for deep inspection |
| Virtual network flow logs | A passive record of IP traffic through a virtual network, for later analysis (traffic analytics) |
| Connection monitor | Continuous, scheduled reachability, round-trip time and failed-check tests with history and alerts |
Reading the results. IP flow verify evaluates the NSGs on both the subnet and the NIC, but it ignores routing and appliances. If it returns Allow while the connection still fails, the cause is past the NSGs, so look at routing: run next hop to see whether a user-defined route sends the packets (or the replies) to a network virtual appliance, which might be down, lack IP forwarding, or be a stateful device that drops a flow because it sees only one of its directions. Next hop type None means the traffic is dropped, and has two sources: a System Route result comes from Azure's default routes for private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10) that are not in your address space or reachable through a peering or gateway, while a result showing a route table resource ID means a user-defined route with next hop None is dropping it.
Flow logs have changed. New NSG flow logs cannot be created since 30 June 2025 and the feature retires on 30 September 2027; virtual network flow logs replace them and cover traffic for the whole virtual network.
Connection monitor versus connection troubleshoot: connection troubleshoot is a single check you run now; Connection monitor runs tests on a schedule (for example every 30 seconds) between sources such as Azure VMs or on-premises machines and destinations such as VMs, URLs or IP:port endpoints, stores round-trip time and check-failure history, and raises alerts when a path degrades.
Tip. Questions are mostly scenarios that hinge on one distinction. Decide which data source holds the answer (platform metric, activity log, resource log through a diagnostic setting, or guest data through the Azure Monitor Agent), then read the constraint: no workspace or lowest cost favours metric and activity log alerts; history beyond 93 days or KQL over metrics means exporting to a workspace; least ongoing effort at scale means category groups or Azure Policy; without editing rules means an alert processing rule. Expect to choose the right aggregation or splitting in metrics explorer, to read a KQL pattern, and to interpret IP flow verify and next hop results when a connection fails.
- Platform metrics are numeric, agentless and near real time, kept for 93 days; logs are records in a Log Analytics workspace queried with KQL.
- In metrics explorer, Max exposes spikes that Avg hides, Sum gives totals and Count is the number of samples; filter restricts what is counted, split draws one series per dimension value.
- The activity log records control-plane operations automatically for 90 days; data-plane reads need resource logs and sign-ins are in Microsoft Entra logs.
- Resource logs exist only through a diagnostic setting: one destination of each type per setting, category groups pick up new categories, and Azure Policy DeployIfNotExists plus remediation covers resources at scale.
- Workspace interactive retention defaults to 30 days and goes up to two years; older data in long-term retention is reached with search jobs or restore.
- Metric and activity log alerts need no workspace; log search alerts query one. Dynamic thresholds learn seasonality, and the number of violations controls persistence.
- Alert rules reference action groups for recipients and actions; alert processing rules suppress or apply action groups on a scope and schedule without editing rules.
- Host VM metrics including available memory are agentless; guest disk free space, event logs and syslog need the Azure Monitor Agent and a data collection rule.
- IP flow verify checks NSG rules only, next hop shows routing (None = dropped), connection troubleshoot is one-off and Connection monitor is continuous; virtual network flow logs replace NSG flow logs.
Frequently asked questions
What is the difference between metrics and logs in Azure Monitor?
Metrics are numeric, time-series values collected automatically in near real time, such as a VM's CPU percentage, and you chart them in metrics explorer without a query language; platform metrics are kept for 93 days. Logs are structured records stored in a Log Analytics workspace, which you query with Kusto Query Language (KQL) to troubleshoot, correlate across resources and audit, with retention you configure. Metrics tell you how much and how fast right now; logs tell you what happened, when and why.
What does the Azure activity log record?
The activity log records control-plane operations on a subscription's resources, such as creating, changing or deleting a resource, editing NSG rules or regenerating storage keys, with the caller, time and status. It is collected automatically and kept for 90 days. It does not record data-plane activity such as reading blobs or key vault secrets (those are resource logs) or user sign-ins (those are Microsoft Entra logs). To keep it longer or query it with KQL, send it to a Log Analytics workspace with a subscription-level diagnostic setting.
How do I send Azure resource logs to a Log Analytics workspace?
Create a diagnostic setting on the resource, choose the log categories or a category group such as allLogs, and select a Log Analytics workspace as the destination. A setting can also send to a storage account for archive, an event hub for SIEM streaming or a partner solution, but only one destination of each type, so a second workspace needs a second setting. Diagnostic settings are per resource and not inherited; use Azure Policy with DeployIfNotExists and a remediation task to cover many resources.
When should I use a dynamic threshold on a metric alert?
Use a dynamic threshold when a metric's normal level changes with time of day or day of week, so a fixed value would either miss real problems or fire constantly. Azure Monitor learns the pattern from history (at least three days, and about three weeks for weekly seasonality) and alerts when the value leaves the expected band. Sensitivity controls how large a deviation counts, while the number of violations within evaluation periods controls how long it must last before the alert fires.
What is the difference between an action group and an alert processing rule?
An action group is a reusable list of notifications (email, SMS, push, voice) and actions (runbook, Function, Logic App, webhook, ITSM) that alert rules call when they fire. An alert processing rule acts on fired alerts at a scope, filtered by things like severity and optionally on a schedule, to suppress action groups or apply an extra action group without editing any alert rule. A processing rule cannot define recipients itself and does not apply to Service Health alerts.
Which VM metrics need the Azure Monitor Agent?
Host-level platform metrics, including CPU, network, disk throughput and operations, and Available Memory Bytes and Available Memory Percentage, are collected without any agent. Data only the guest operating system can see, such as free space per logical disk, page file usage, process counters, Windows event logs and Linux syslog, needs the Azure Monitor Agent and a data collection rule. Guest counters sent to Azure Monitor Metrics appear under a separate guest metrics namespace in metrics explorer.
What is the difference between IP flow verify, next hop and Connection monitor?
IP flow verify tells you whether network security group rules on the subnet and NIC would allow or deny a specific flow and names the rule, but it ignores routing. Next hop shows which route a VM uses for a destination; a next hop type of None means the traffic is dropped, by a default system route or by a user-defined route. Connection monitor runs scheduled reachability and latency tests between endpoints, keeps history and raises alerts, unlike the one-time connection troubleshoot check.
Are NSG flow logs still available in Azure?
No new NSG flow logs can be created since 30 June 2025, and the feature retires on 30 September 2027. Virtual network flow logs, also part of Network Watcher, replace them: they record IP traffic for an entire virtual network and can feed traffic analytics. Existing NSG flow logs keep working until retirement, but new monitoring should use virtual network flow logs.
Source
This lesson covers the "Monitor and maintain Azure resources" domain of the official AZ-104 exam guide. Vendors revise their guides — check the source for the current version.
- Microsoft AZ-104 study guide — Microsoft Learn
Sign up free to mark lessons complete, bookmark topics and track your exam readiness.