Routing Logs with Diagnostic Settings and Data Collection Rules
This lesson explains the kinds of Azure logs, diagnostic settings, data collection from VMs and Log Analytics workspace settings.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish between the activity log, resource logs and guest OS logs.
- Choose a diagnostic setting destination for a requirement.
- Describe the Azure Monitor Agent, data collection rules and workspace retention.
Kinds of logs
Azure has three main kinds of platform logs. The activity log records subscription-level control plane events: who created, changed or deleted a resource, service health events, autoscale and policy actions. It is collected automatically and kept for 90 days. Resource logs record operations inside a resource, such as Key Vault secret reads, storage blob requests, NSG rule counters or Azure SQL query statistics; they are not collected until a diagnostic setting routes them. Microsoft Entra logs (sign-ins and audit) are routed from Microsoft Entra ID's own diagnostic settings.
Which log records it?
Diagnostic settings
A diagnostic setting on a resource selects log categories (or category groups such as allLogs and audit) and optionally metrics, and sends them to one or more destinations. Each resource can have up to five diagnostic settings, and the activity log has its own diagnostic setting at subscription level.
At scale, Azure Policy built-in definitions with DeployIfNotExists create diagnostic settings for every resource of a type, so new resources are covered automatically. Logs sent to a workspace land in tables such as AzureDiagnostics (legacy shared table) or resource-specific tables such as StorageBlobLogs and AzureFirewallNetworkRule, which are preferred.
The following diagram shows a policy, the diagnostic setting it deploys and the two destinations for auditing secret reads across 40 key vaults.

Choosing a destination
Collecting data from VMs
Logs from inside VMs, such as Windows event logs, Linux syslog, performance counters and text logs, are collected by the Azure Monitor Agent (AMA), an extension installed on Windows and Linux VMs, scale sets and Arc-enabled servers. What to collect and where to send it are defined in data collection rules (DCRs), which are associated with machines; one DCR can serve many machines, and a machine can have several DCRs. The legacy Log Analytics agent (MMA/OMS) retired on 31 August 2024 and must not be used.
Agents and data collection rules
Log Analytics workspaces
A Log Analytics workspace stores log data in tables. Its settings include retention (the Analytics plan includes 31 days, configurable per workspace or table up to two years of interactive retention and up to 12 years in total with long-term retention), table plans (Analytics for full querying and alerts, Basic and Auxiliary for high-volume, lower-cost logs with limited querying), a daily cap to limit ingestion, and the access control mode (workspace or resource-context permissions). Commitment tiers reduce cost for high ingestion volumes.
Workspace settings
Auditing Key Vault access
The security team must be able to query who read secrets from 40 key vaults over the last year and to keep the raw logs for seven years at the lowest cost. New key vaults must be covered automatically. What should you configure?
Assign the built-in DeployIfNotExists policy that configures diagnostic settings for Key Vault, sending the AuditEvent category to a Log Analytics workspace with one year of retention for querying, and to a storage account for the seven-year archive (or use workspace long-term retention). Create a remediation task for the existing vaults. The activity log would show changes to the vaults but not secret reads, which are data plane operations.
Are Key Vault resource logs collected without any configuration?
Show answer
No. Resource logs need a diagnostic setting that routes them to a destination.
Exam Tips
Remember for the exam
- Resource logs need a diagnostic setting; the activity log is collected automatically for 90 days.
- Send logs to Log Analytics to query and alert; to storage to archive; to Event Hubs to stream.
- Collect guest OS logs with the Azure Monitor Agent and data collection rules.
- Deploy diagnostic settings at scale with DeployIfNotExists policies.