Lesson 3 of 4 Logging and Monitoring Solutions

Routing Logs to the Right Destination

This lesson explains how diagnostic settings and data collection rules deliver logs to their consumers.

Learning outcomes

After completing this lesson, you will be able to:

  • Choose a log destination for a stated consumer.
  • Describe diagnostic settings at resource, subscription and tenant levels.
  • Explain how Azure Policy applies log routing at scale.

Diagnostic settings and their destinations

A diagnostic setting routes the resource logs and metrics of one Azure resource. Each destination has a distinct purpose, and a good design selects the destination according to how the data will be consumed.

Log Analytics workspace

This destination is chosen when the data will be queried, correlated with other data or used for alerts. Sending logs here enables KQL, workbooks, log alerts and Microsoft Sentinel. It is the default choice for operational and security logs.

Azure Storage account

A storage account is the low-cost destination for archiving logs. Data is written to blobs, where it can sit under lifecycle management rules and immutability policies. It is suitable when a regulation requires retention but the data will rarely be read. Querying it is inconvenient, because there is no KQL engine over the blobs.

Azure Event Hubs

An event hub streams logs to any consumer that reads from it, in near real time. This is the standard path to a third-party SIEM or log analytics platform running outside Azure. The event hub acts as a buffer, so the external system does not need a direct connection to each Azure resource.

Azure Monitor partner solutions

Certain partner products, such as Datadog and Elastic, are integrated directly as a destination. Partner solutions avoid the operation of an event hub when the organization already uses one of the supported products.

A single diagnostic setting can define no more than one of each destination type, and a resource can have up to five diagnostic settings. To send logs to the same type of destination twice, such as two workspaces, create a second diagnostic setting. The following table summarizes the destinations.

DestinationRequirement it meetsLimitation
Log Analytics workspaceQuery, correlate, alert, feed Microsoft SentinelHigher cost for high-volume data
Azure Storage accountLow-cost archive, immutable retentionNo interactive query
Azure Event HubsStream to an external SIEM or custom consumerNot a long-term store
Partner solutionDirect integration with a supported productLimited to listed partners

The following diagram shows one diagnostic setting that routes the audit logs of 200 Azure SQL databases to three destinations.

Routing audit logs from 200 Azure SQL databases to three consumers. A DeployIfNotExists policy gives every database, including new ones, a diagnostic setting with three destinations: an event hub streams to the on-premises SIEM within minutes, a Log Analytics workspace serves the operations team's KQL, and immutable storage keeps the logs unchanged for seven years at minimum cost.
The scenario is illustrative.
Match the pairs

Diagnostic setting destinations

Exam skills 1.1.2

Match each diagnostic setting destination with the requirement it meets.

Log in to try this activity Interactive activities are free with an account.

Routing at the subscription and tenant levels

Diagnostic settings exist at more than the resource level, and a complete design covers all levels. A subscription diagnostic setting exports the activity log, so that control plane history survives beyond the 90 days held by the platform. Microsoft Entra diagnostic settings export sign-in and audit logs from the tenant, which matters because Entra keeps these logs for a limited period, shorter on free licences. These settings are configured in the Microsoft Entra admin center rather than on a resource.

Log routing should be enforced rather than left to individual deployments. Built-in Azure Policy definitions, usually with the deployIfNotExists effect, can create the diagnostic setting on any new resource of a given type and can remediate existing resources. Assigning such a policy at a management group means that new subscriptions inherit the logging standard automatically.

Scenario questions

Routing beyond resources

Exam skills 1.1.2

Choose how to route logs that do not come from an individual resource.

Log in to try this activity Interactive activities are free with an account.

Routing from inside machines

Data collected by the Azure Monitor Agent is routed by data collection rules rather than by diagnostic settings. A DCR can send security events to one workspace and performance counters to another, which is useful when a security team and an operations team have separate workspaces. This is known as multihoming, and the agent supports it without running multiple agents.

Servers outside Azure, whether on-premises or in another cloud, first become Azure Arc-enabled servers. They then appear as Azure resources and can receive the Azure Monitor Agent and data collection rules, so a single design covers Azure and hybrid machines.

True or false

Agent-based routing

Exam skills 1.1.2

Check how data from inside machines is routed.

Log in to try this activity Interactive activities are free with an account.

Moving data after ingestion

Sometimes data must leave the workspace after it has been stored. Log Analytics workspace data export continuously sends selected tables to a storage account or event hub as data arrives. It suits integration with other systems and long-term data lake storage. Because the rule works on the tables rather than on individual resources, one rule can cover many sources.

Private access to monitoring is handled by an Azure Monitor Private Link Scope, which connects a virtual network to monitoring resources through private endpoints. It is the recommendation when agents or applications must reach Azure Monitor without traversing public endpoints. One scope covers a group of workspaces and Application Insights resources, and since it affects DNS for the whole network, Microsoft recommends a single scope per private network.

Worked example

Routing to three consumers

A bank has 200 Azure SQL databases. Database audit logs must be available to its on-premises third-party SIEM within minutes, must be queryable by the Azure operations team, and must be retained unchanged for seven years at minimum cost. Every new database must be covered automatically. What should you recommend?

Three consumers lead to three destinations. The on-premises SIEM needs a stream, so one destination is an event hub. Operations needs KQL queries, so another is a Log Analytics workspace. Seven-year, tamper-proof retention at minimum cost points to a storage account with an immutability policy and a cool or archive tier.

All three can be defined in one diagnostic setting, because it uses one destination of each type. An Azure Policy assignment with deployIfNotExists covers new databases automatically. Long-term retention in the workspace could meet the seven-year requirement, but blob storage with a locked immutability policy provides explicit write-once protection at a lower cost, and a partner solution would not reach an on-premises product.

Check yourself

Can one diagnostic setting send logs to two different Log Analytics workspaces?

Show answer

No. A setting holds one destination of each type, so a second diagnostic setting is required. A resource can have up to five.

Exam Tips

Remember for the exam

  • Workspace to query, storage to archive, event hub to stream to an external SIEM.
  • One diagnostic setting holds one destination of each type; a resource has at most five settings.
  • Export the activity log and Entra logs with their own diagnostic settings.
  • Use Azure Policy with deployIfNotExists to apply diagnostic settings at scale.