Lesson 19 — Azure Monitor: Metrics, Logs & Alerts
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.
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 Service | Example Platform Metrics |
|---|---|
| Virtual Machines | Percentage CPU, Network In/Out, Disk Read/Write Bytes, Disk IOPS |
| Storage Account | Transactions, Ingress, Egress, Availability, SuccessE2ELatency |
| Azure SQL Database | DTU consumption %, CPU percentage, Data IO percentage, Storage |
| App Service | Requests, HTTP server errors, Response time, CPU time, Memory working set |
| Azure Load Balancer | Packet 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)
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 Type | Source | What it contains | Collection 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.
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.
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 capability | Details |
|---|---|
| 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) |
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
| Destination | Use Case | Notes |
|---|---|---|
| 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. |
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
Retention and forwarding
| Configuration | Details |
|---|---|
| Default retention | 90 days in the Activity Log — after that, entries are deleted |
| Extended retention | Create a diagnostic setting on the Activity Log to send entries to a Log Analytics workspace (query with KQL) or storage account (archive) |
| Real-time streaming | Send Activity Log to an Event Hub for real-time SIEM ingestion |
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 Type | Signal | Evaluation | Use 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 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 Type | Description |
|---|---|
| Email / SMS / Push notification | Direct notification to on-call engineers via email, SMS, or Azure mobile app |
| Voice call | Automated phone call — for critical Severity 0 alerts requiring immediate response |
| Webhook | HTTP POST to any endpoint — integrates with PagerDuty, OpsGenie, Slack, etc. |
| Logic App | Trigger a Logic App workflow — complex orchestration, conditional logic, multi-step remediation |
| Azure Function | Run a serverless function — custom remediation code (e.g. auto-scale, restart a service) |
| Automation Runbook | Run an Azure Automation runbook — remediation workflows (e.g. remediate disk space, restart VM) |
| ITSM connector | Create a ticket in ServiceNow, JIRA Service Management, etc. |
| Event Hub | Stream alert data to an Event Hub for downstream processing |
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.
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).
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?
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?
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?
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?
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?
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?
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.
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?