Lesson 19 — Azure Monitor: Metrics, Logs & Alerts

Domain 5 — Monitor & Maintain AZ-104: 10–15% ~35 min Prereq: Resource hierarchy, VMs, Storage

Why Monitoring Is Tested Differently from Other Domains

The monitoring domain in AZ-104 does not just test whether you know what Azure Monitor is — it tests whether you can configure monitoring correctly: which agent to use, what a diagnostic setting routes, where the Activity Log is stored, what an Action Group does, and the difference between a metric alert and a log search alert.

In production, monitoring failures are silent. A misconfigured diagnostic setting means audit logs are never collected. A missing agent means VM performance data is missing from dashboards. An alert without a correctly configured Action Group fires and notifies nobody. This lesson covers every component you need to configure monitoring correctly from first principles.

1. Azure Monitor — The Unified Platform

Azure Monitor is Microsoft's single unified monitoring platform for all Azure resources, hybrid VMs, and applications. It collects, analyses, and acts on telemetry from every layer of your Azure environment.

Azure Monitor ├─ Data Sources │ ├─ Azure resources (platform metrics, resource logs) │ ├─ VMs (Azure Monitor Agent → DCR) │ ├─ Applications (Application Insights SDK) │ └─ Custom sources (REST API, OpenTelemetry) ├─ Data Types │ ├─ Metrics — numeric time-series (93 days, free) │ └─ Logs — structured records in Log Analytics Workspace └─ Analysis & Action ├─ Metric Explorer (visualise, analyse metrics) ├─ Log Analytics (KQL queries over logs) ├─ Alerts (metric, log, activity log, resource health) ├─ Workbooks (interactive reports) └─ Dashboards (portal pin-boards)
Metrics vs. Logs — the core distinction Metrics are lightweight numeric time-series values collected automatically at no cost (e.g. CPU%, bytes sent, request count). They are stored for 93 days in a specialised time-series database. Logs are richer structured records stored in a Log Analytics workspace. They require explicit configuration to collect and incur cost beyond the 30-day free retention period. Logs are queried with KQL (covered in Lesson 20).

2. Metrics

Metrics are numeric time-series data points emitted by Azure resources at regular intervals (typically 1-minute granularity). They are designed for fast, real-time monitoring and alerting.

Platform metrics — automatic and free

Most Azure services emit platform metrics automatically. No agent, diagnostic setting, or configuration is required. They appear immediately in Metric Explorer as soon as a resource is created.

Azure ServiceExample Platform Metrics
Virtual MachinesPercentage CPU, Network In/Out, Disk Read/Write Bytes, Disk IOPS
Storage AccountTransactions, Ingress, Egress, Availability, SuccessE2ELatency
Azure SQL DatabaseDTU consumption %, CPU percentage, Data IO percentage, Storage
App ServiceRequests, HTTP server errors, Response time, CPU time, Memory working set
Azure Load BalancerPacket count, Byte count, Health probe status, SNAT connection count

Metric dimensions

Many metrics support dimensions — additional properties that let you split a metric by a categorical attribute. For example, the Requests metric on an App Service can be split by the HttpStatusCode dimension to see how many requests returned 200, 404, or 500 separately.

Custom metrics

Applications can emit custom business metrics directly to Azure Monitor via the Azure Monitor REST API, Azure Monitor SDK, or OpenTelemetry. Custom metrics appear in Metric Explorer alongside platform metrics. They are billed based on the number of metric series ingested.

Metric Explorer

Metric Explorer is the portal tool for visualising and analysing metrics. Key capabilities:

  • Plot multiple metrics from multiple resources on the same chart
  • Apply aggregations: average, maximum, minimum, sum, count
  • Split by dimension (e.g. CPU per VM in a VMSS)
  • Add filters (e.g. show only East US resources)
  • Pin charts to shared dashboards
  • Set the time range from 30 minutes to 30 days (93 days of data available)
93-day retention — automatic, no configuration needed Platform metrics are stored for 93 days at no cost with no configuration. This is different from Logs, which default to 30 days and require configuration and cost for extended retention. If you need metrics beyond 93 days, export them to a Storage Account or Log Analytics workspace using a diagnostic setting.

3. Logs and Log Analytics Workspaces

Logs are richer, structured records stored in a Log Analytics workspace — a dedicated storage and analytics engine built on Azure Data Explorer. Unlike metrics, logs require explicit configuration to collect, and they incur cost based on data ingestion volume and retention.

Log types

Log TypeSourceWhat it containsCollection mechanism
Resource Logs Azure resources Operations that happened within a resource (e.g. Key Vault: who accessed which secret; Storage: which blob was read) Diagnostic setting on the resource
Activity Log Azure subscription Control-plane operations on Azure resources (create, delete, modify — who did what, when) Auto-collected; send to Log Analytics via diagnostic setting for long-term retention
Entra ID Logs Microsoft Entra ID Sign-in events, audit log (user/group/role changes) Diagnostic setting on Entra ID tenant
VM Performance Counters VMs (Windows / Linux) CPU, memory, disk, network at the OS level Azure Monitor Agent + Data Collection Rule
Windows Event Logs / Syslog VMs (Windows / Linux) OS events, application events, security events Azure Monitor Agent + Data Collection Rule

Log Analytics workspace

All Azure Monitor logs land in a Log Analytics workspace. Key facts:

  • A workspace is a single Log Analytics resource deployed to a region — data is stored in that region.
  • Multiple resources, subscriptions, and even tenants can send logs to the same workspace.
  • Logs are stored in tables within the workspace (e.g. AzureActivity, SecurityEvent, Heartbeat, Perf).
  • Queried with KQL (Kusto Query Language) — covered in Lesson 20.
  • Default retention: 30 days free. Configurable up to 2 years (charges apply after 30 days).
  • Data older than the interactive retention period can be archived to cheaper storage for up to 7 years.
Workspace design: centralised vs. decentralised Most organisations use a centralised Log Analytics workspace model — one workspace per region, all resources in that region send logs there. This simplifies KQL queries (all data is co-located), reduces cost (pricing tiers apply at workspace level), and centralises access control. Decentralised workspaces per-team or per-application add complexity without proportionate benefit in most cases.

4. Azure Monitor Agent (AMA) and Data Collection Rules

For VMs, platform metrics cover resource-level data (CPU%, disk IOPS from the hypervisor). But to collect OS-level data — Windows Event Logs, Syslog, IIS logs, custom performance counters — you must install an agent inside the VM. The Azure Monitor Agent (AMA) is the current, recommended agent.

Agent consolidation — critical for the exam There were previously three separate agents: Log Analytics Agent (MMA/OMS), Azure Diagnostics Extension (WAD/LAD), and Dependency Agent. The Azure Monitor Agent replaces all of them. The older agents are being deprecated. On the exam, when asked about collecting VM logs and performance data, the answer is always Azure Monitor Agent + Data Collection Rule.

Data Collection Rules (DCRs)

The AMA is configured via Data Collection Rules — Azure resources that define:

  • What data to collect: which Windows Event Log channels (System, Security, Application), which Syslog facilities (kern, daemon, auth), which performance counter names and sample rates, IIS log paths
  • Where to send it: one or more Log Analytics workspaces (or Azure Monitor workspace for metrics)
  • Transformations: filter or reshape data before ingestion (e.g. drop verbose debug events)
DCR capabilityDetails
Multi-target A single DCR can be associated with many VMs — configure once, apply broadly
Multi-DCR per VM A single VM can have multiple DCRs associated — useful when different teams manage different data streams
Data destinations Log Analytics workspace (for KQL querying), Azure Monitor workspace (for Prometheus metrics), Event Hub (streaming), Storage Account
Deployment AMA installed via VM extension (AzureMonitorWindowsAgent / AzureMonitorLinuxAgent) or automatically via Azure Policy (Deploy If Not Exists)
Azure Policy for automatic agent deployment The built-in policy initiative Enable Azure Monitor for VMs uses Deploy If Not Exists (DINE) effects to automatically install AMA and associate a DCR on any VM that does not have it. Assign this initiative at the management group or subscription scope so all new VMs are automatically onboarded to monitoring.

5. Diagnostic Settings

For Azure PaaS resources (not VMs), you configure a diagnostic setting on the resource to route its platform logs and metrics to one or more destinations. This is separate from the Azure Monitor Agent (which is for VMs only).

What a diagnostic setting routes

  • Resource logs (formerly "diagnostic logs"): operations that happened within the resource. Categories are service-specific (e.g. for Key Vault: AuditEvent; for SQL: SQLSecurityAuditEvents, QueryStoreRuntimeStatistics).
  • Metrics: platform metrics sent to a Log Analytics workspace (where they can be queried with KQL) or to a storage account for archiving.

Destination options

DestinationUse CaseNotes
Log Analytics Workspace KQL querying, alerts, Workbooks Most flexible — enables cross-resource correlation and alerting
Storage Account Long-term archiving, compliance, cost-effective retention Stored as JSON blobs. Not queryable directly without additional tooling.
Event Hub Real-time streaming to SIEM (Sentinel, Splunk, Elastic), third-party tools High throughput streaming. Requires a consumer to process the stream.
Partner solution Direct integration with Datadog, Elastic, Dynatrace, etc. Bypasses intermediate storage — data goes directly to the partner platform.
Up to 5 diagnostic settings per resource Each Azure resource can have up to 5 diagnostic settings simultaneously. This allows you to, for example, send audit logs to a central security workspace AND archive them to a storage account AND stream them to an Event Hub for real-time SIEM ingestion — all from the same diagnostic setting configuration.

Common exam scenario: configuring resource logs

Resource: Key Vault "prod-kv-eastus"
Diagnostic setting: "send-to-law-and-archive"
  ├─ Log categories: AuditEvent (who accessed which secret/key/cert)
  ├─ Destination 1: Log Analytics Workspace "law-central-eastus" (retention: 90 days)
  └─ Destination 2: Storage Account "starchiveprod001" (archiving: 2 years)

6. Activity Log

The Activity Log records all control-plane operations on Azure resources within a subscription. Every time anyone — a user, a managed identity, a service principal, or Azure itself — creates, modifies, or deletes an Azure resource, an Activity Log entry is created.

What the Activity Log captures

  • Who performed the operation (identity: user UPN, service principal, managed identity)
  • What operation was performed (resource type + operation name, e.g. Microsoft.Compute/virtualMachines/write)
  • When it happened (timestamp)
  • What the result was (Succeeded, Failed, Accepted)
  • Which resource was affected (resource ID)
  • The source IP of the operation
Activity Log scope: subscription, not resource The Activity Log is a subscription-level construct, not a per-resource one. A single Activity Log covers all operations across all resources in a subscription. To view the Activity Log, navigate to the subscription and select Activity Log, or search for "Activity Log" in the portal to see a cross-subscription view.

Retention and forwarding

ConfigurationDetails
Default retention90 days in the Activity Log — after that, entries are deleted
Extended retentionCreate a diagnostic setting on the Activity Log to send entries to a Log Analytics workspace (query with KQL) or storage account (archive)
Real-time streamingSend Activity Log to an Event Hub for real-time SIEM ingestion
Activity Log for security investigations When investigating a security incident — "who deleted the storage account?" or "who changed the NSG rules at 2am?" — the Activity Log is your first stop. It gives you a precise, immutable record of every control-plane operation. Send it to Microsoft Sentinel or your SIEM for automated correlation and alerting on suspicious activity patterns.

7. Alerts

Azure Monitor alerts evaluate a signal (metric, log query result, activity log event) on a schedule and fire an alert when the signal meets a defined condition. Alerts are composed of three parts: the alert rule, the action group, and the alert state.

Alert rule types

Alert TypeSignalEvaluationUse Case
Metric alert Platform or custom metric Near-real-time (1-minute frequency) CPU > 90%, memory > 85%, disk latency spike
Log search alert KQL query against Log Analytics Runs on a schedule (minimum 1 minute) "Alert if more than 10 failed logins in 5 minutes"
Activity log alert Activity Log events Near-real-time on event match "Alert when any resource in subscription is deleted"
Resource health alert Azure platform health events Platform-pushed "Alert when a VM becomes unavailable due to a platform issue"

Static vs. dynamic thresholds for metric alerts

Metric alerts support two threshold types:

  • Static threshold: a fixed numeric value (e.g. CPU > 85%). Simple, predictable, but can produce false positives for workloads with expected patterns (e.g. Monday morning CPU spikes).
  • Dynamic threshold: uses machine learning to learn the metric's normal pattern over time (including daily/weekly seasonality) and alerts when the metric deviates abnormally from the learned baseline. Reduces alert fatigue for variable workloads.
Alert severity levels Severity 0 (Critical) through Severity 4 (Verbose). Severity drives routing and escalation policies in Action Groups and ITSM integrations. Severity 0 and 1 alerts should trigger immediate page/call; Severity 3 and 4 can be informational tickets.

Alert states

Once fired, alerts go through a lifecycle:

  • Fired: condition met, action group executed, notifications sent
  • Acknowledged: engineer has seen and is investigating the alert (suppresses re-notifications)
  • Resolved: condition no longer met (metric-based alerts auto-resolve; log alerts require manual resolution)

8. Action Groups

An Action Group is a reusable collection of notification and remediation actions that are executed when an alert fires. Action groups decouple the what happened (the alert rule) from what to do about it (the action group), enabling the same response process to be triggered by multiple different alerts.

Action types

Action TypeDescription
Email / SMS / Push notificationDirect notification to on-call engineers via email, SMS, or Azure mobile app
Voice callAutomated phone call — for critical Severity 0 alerts requiring immediate response
WebhookHTTP POST to any endpoint — integrates with PagerDuty, OpsGenie, Slack, etc.
Logic AppTrigger a Logic App workflow — complex orchestration, conditional logic, multi-step remediation
Azure FunctionRun a serverless function — custom remediation code (e.g. auto-scale, restart a service)
Automation RunbookRun an Azure Automation runbook — remediation workflows (e.g. remediate disk space, restart VM)
ITSM connectorCreate a ticket in ServiceNow, JIRA Service Management, etc.
Event HubStream alert data to an Event Hub for downstream processing
Action Groups are reusable — this is the exam point Create one Action Group called "Critical-On-Call" with email, SMS, and PagerDuty webhook configured. Attach this single Action Group to all Severity 0 and Severity 1 alert rules across all resources and subscriptions. When the on-call rotation changes, update the Action Group in one place and all alert rules are automatically updated.
Action Group rate limits Each Action Group has rate limits to prevent alert storms from flooding notification channels. Email: 100 emails/hour. SMS: 1 per 5 minutes per phone number. Webhook: 10 per minute. If alerts fire faster than these limits, some notifications may be suppressed. Use Smart Groups to reduce alert volume before it reaches Action Groups.

9. Smart Groups and Workbooks

Smart Groups

When a widespread issue occurs (e.g. a networking outage affecting 50 VMs), Azure Monitor can fire 50 separate CPU alerts and 50 separate disk alerts — creating 100 notifications for what is essentially one problem. Smart Groups use ML to automatically correlate related alerts into a single Smart Group, reducing alert noise and enabling engineers to triage the root cause rather than processing individual alert instances.

Smart Groups do not replace alert rules Smart Groups operate on fired alerts — they are a presentation and management layer on top of existing alerts. You still need well-configured alert rules. Smart Groups just ensure that when 50 alerts fire due to the same root cause, the on-call engineer sees one Smart Group to investigate, not 50 separate alert notifications.

Azure Monitor Workbooks

Workbooks are interactive, parameterised reports in the Azure portal that combine metrics, logs (KQL queries), rich text, and interactive controls (dropdowns, time range pickers) into a single reusable document. They are ideal for:

  • Executive-level dashboards showing SLA compliance, availability, and cost trends
  • Operational runbooks — a Workbook can both show diagnostic data and link to remediation steps
  • Cross-resource analysis — combine metrics from VMs, databases, and load balancers on one canvas
  • Shared team views — Workbooks can be saved to a Resource Group and shared via RBAC

10. Application Insights (Overview)

Application Insights is the application performance monitoring (APM) component of Azure Monitor. It provides code-level telemetry: request rates, response times, exception rates, dependency tracking (calls to databases, external APIs), distributed tracing, and user behaviour analytics.

For the AZ-104 exam, Application Insights is in scope at a high level. You need to understand what it does without deep configuration knowledge (which is more relevant to AZ-204 Developer exam):

  • Application Insights requires an SDK or auto-instrumentation to be added to the application code (or App Service can enable auto-instrumentation without code changes).
  • Data is stored in a Log Analytics workspace (workspace-based Application Insights) or in a classic Application Insights resource.
  • Use Application Insights for application-level metrics (failed requests, exceptions, custom events) — use platform metrics for infrastructure-level data (CPU, disk).
  • Smart Detection: automatic anomaly detection for application metrics (e.g. sudden spike in failure rate).
AZ-104 exam scope for Application Insights You are unlikely to be tested on SDK instrumentation or Application Map configuration. However, you may see questions asking: which Azure Monitor component monitors application-level performance? The answer is Application Insights. What component monitors VM OS performance? The answer is Azure Monitor Agent with Data Collection Rules.

Check Your Understanding

Click any option to see immediate feedback. Answers reflect real Azure Monitor behaviour.

1. You deploy a new Azure Virtual Machine. Without any additional configuration, which of the following metrics are automatically available in Azure Monitor Metric Explorer?

Platform metrics (CPU%, Network In/Out, Disk Read/Write Bytes, etc.) are automatically collected from Azure VMs by the Azure hypervisor and are available in Metric Explorer immediately with no agent, no diagnostic setting, and no cost. They are stored for 93 days. The Azure Monitor Agent is needed for OS-level data (Windows Event Logs, Syslog, performance counters inside the OS) — not for platform metrics.

2. You need to collect Windows Security Event Logs from 50 Azure VMs and send them to a central Log Analytics workspace for KQL querying and alerting. What is the correct configuration?

Windows Event Logs are OS-level data inside the VM — they require an agent. The Azure Monitor Agent (AMA) is the current recommended agent. A Data Collection Rule (DCR) specifies what to collect (in this case, the Windows Security event log channel) and where to send it (the Log Analytics workspace). The DCR can target all 50 VMs simultaneously. Diagnostic settings on a VM only route VM-level platform metrics and Azure resource logs — not OS-level event logs.

3. Your security team needs all Azure Key Vault access logs routed to a Log Analytics workspace for KQL-based threat hunting, archived to a Storage Account for 3-year compliance retention, and streamed to an Event Hub for real-time Splunk ingestion. Is this possible with a single diagnostic setting?

A single diagnostic setting on an Azure resource can route to multiple destinations simultaneously: one or more Log Analytics workspaces, a Storage Account, an Event Hub, and a partner solution — up to 5 destinations in total. You do not need separate diagnostic settings per destination. All three destinations (Log Analytics workspace for KQL, Storage Account for archiving, Event Hub for Splunk) can be configured in one diagnostic setting on the Key Vault.

4. An engineer deletes a production storage account by mistake. You need to determine exactly who deleted it, when, and from which IP address. What is the correct Azure Monitor tool to use?

Resource deletion is a control-plane operation — it goes through Azure Resource Manager, not through the storage account's data plane. The Activity Log records all ARM control-plane operations: who performed the operation (identity), what operation (Microsoft.Storage/storageAccounts/delete), when, the result, and the caller's IP address. Platform metrics do not record who performed an operation. Resource Logs capture data-plane operations within a resource (e.g. blob read/write) — not control-plane deletions of the resource itself.

5. You have 15 different alert rules across VMs, databases, and load balancers — all requiring the same response: email the on-call team, send a PagerDuty webhook, and create a ServiceNow ticket. What is the most operationally correct approach?

Action Groups are designed exactly for this scenario: create one reusable Action Group ("Critical-On-Call") with all required actions, then attach it to all 15 (or 150) alert rules. When the on-call engineer changes, update the Action Group once — all 15 rules are automatically updated. Configuring actions on each alert rule individually multiplies maintenance burden by 15 and increases the risk of configuration drift.

6. You configure a CPU metric alert with a static threshold of 80% on a web application VM. The alert fires every Monday morning at 9am when the batch processing job runs, even though this is expected and normal behaviour. What alert type should you switch to in order to reduce these false positives?

Dynamic thresholds use machine learning to analyse the metric's historical behaviour and learn its normal patterns — including daily and weekly seasonality like Monday morning CPU peaks. Once learned, the dynamic threshold alert only fires when the metric deviates abnormally from its expected pattern. Increasing the static threshold would mask genuinely abnormal CPU spikes on other days. Dynamic thresholds provide the right balance between sensitivity and false-positive reduction for metrics with predictable patterns.
Primary source for this lesson Azure Monitor overview — Microsoft Learn

Also read: Azure Monitor Agent overview, Data Collection Rules, Diagnostic settings overview, and the Alert rules documentation. The Activity Log documentation is particularly important — read the section on sending Activity Log to a Log Analytics workspace for long-term retention.

Questions for your teacher (the AI agent)
This lesson covered Azure Monitor's data collection, alerting, and action architecture. Dig deeper:
  • Walk me through creating a complete Azure Monitor alert with a dynamic threshold, Action Group, and ITSM integration using Bicep.
  • What is the difference between a Log Analytics workspace and an Azure Monitor workspace, and when would I use each?
  • How do Data Collection Rules work with transformations — show me an example that drops verbose debug events before ingestion.
  • How do I set up Microsoft Sentinel on top of a Log Analytics workspace and what built-in analytics rules cover common attack patterns?
Coming up: Lesson 20 — KQL and Log Analytics You have configured Azure Monitor to collect logs into a Log Analytics workspace. The next lesson teaches you to query them. Kusto Query Language (KQL) is how you extract insight from the data — filtering, aggregating, joining tables, and building alert queries. KQL competency directly translates to troubleshooting speed and exam performance.