← Back to Articles         
Data Collection Rule (DCR) in Azure

Data Collection Rule (DCR) in Azure

Published on 20 Oct 2026     15 min read Microsoft AZURE
Data Collection Rule (DCR) in Azure
 

What is a Data Collection Rule (DCR) in Azure?

A Data Collection Rule (DCR) in Azure Monitor defines what monitoring data to collect, how to process it, and where to send it.

In simple terms, a DCR acts like a filter and routing configuration for collecting logs and performance data from Azure resources.

1. Why do we need a Data Collection Rule?

Suppose you have an Azure Virtual Machine running an ASP.NET Core application.

You want to collect:

  • CPU and memory performance counters.

  • Windows Event Logs.

  • Application logs.

  • Only specific events instead of collecting everything.

Without filtering, unnecessary data collection can increase storage and ingestion costs.

A DCR helps control which data is collected and sent to a destination such as a Log Analytics Workspace.

2. How does a Data Collection Rule work?

       Azure Virtual Machine
                |
                v
       Azure Monitor Agent
             (AMA)
                |
                v
      Data Collection Rule
      --------------------
      1. Select Data Source
      2. Filter / Transform
      3. Define Destination
      --------------------
                |
                v
      Log Analytics Workspace
                |
                v
          KQL Queries
                |
                v
       Alerts / Workbooks

Example:

You configure a DCR to collect Windows Application and System event logs from a VM.

The Azure Monitor Agent collects the configured events and sends them to the Log Analytics Workspace according to the DCR.

3. Main components of a DCR

Component

Description

Data Sources

Specifies what data to collect, such as Windows events or performance counters.

Data Streams

Identifies the type and schema of collected data.

Transformations

Uses KQL to filter or transform data before ingestion, where supported.

Destinations

Defines where the collected data should be sent.

Data Flows

Connects streams and transformations to destinations.

Resources

Identifies resources associated with the rule, where applicable.

4. Real-time example

Assume you have three Azure Virtual Machines.

You want to collect only Windows Error events and send them to one Log Analytics Workspace.

        VM-01       VM-02       VM-03
          |           |           |
         AMA         AMA         AMA
          |           |           |
          +-----------+-----------+
                      |
                      v
            Data Collection Rule
             (Windows Errors)
                      |
                      v
           Log Analytics Workspace
                      |
                      v
                 Event Table
                      |
                      v
                  KQL Query

A DCR can be associated with multiple VMs, allowing them to use the same collection configuration.

5. How to create a DCR in Azure Portal

Step 1: Open Azure Portal

Navigate to Azure Portal and search for Monitor.

Step 2: Open Data Collection Rules

Navigate to:

Monitor → Settings → Data Collection Rules → Create

Step 3: Configure the rule

Enter the following details:

Setting

Example

Rule Name

dcr-vm-monitoring

Subscription

Your Azure subscription

Resource Group

rg-monitoring

Region

East US

Platform Type

Windows

Step 4: Add Resources

Select the Azure Virtual Machine you want to monitor. Ensure the Azure Monitor Agent is installed or enable its installation through the configuration workflow.

Step 5: Add Data Sources

Choose Windows Event Logs or Performance Counters.

For example, select Windows Application and System logs with Error severity.

Step 6: Select Destination

Choose:

Azure Monitor Logs → Your Log Analytics Workspace

Step 7: Create

Select Review + Create → Create.

Once the rule is associated with the VM and data starts flowing, you can query the collected events.

6. Verify collected data using KQL

Open:

Log Analytics Workspace → Logs

Execute:

Event
| where TimeGenerated > ago(1h)
| where EventLevelName == "Error"
| project TimeGenerated, Computer,
          Source, EventID, RenderedDescription
| order by TimeGenerated desc

This query displays Windows Error events collected during the last hour.

7. DCR vs Diagnostic Settings

Data Collection Rule

Diagnostic Settings

Configures collection and processing for supported data sources.

Routes supported Azure resource and platform logs and metrics.

Commonly used with Azure Monitor Agent.

Commonly used with Azure services such as App Service and Azure SQL.

Supports collection configuration and certain transformations.

Selects supported log and metric categories for export.

Uses data flows and destinations.

Sends data to destinations such as Log Analytics, Storage, and Event Hubs.

Important: Not every Azure monitoring scenario requires a DCR. For example, Azure Activity Logs are typically exported to Log Analytics using Diagnostic Settings, while VM guest operating system logs are commonly collected using DCRs and Azure Monitor Agent.

8. Important interview questions

Q1. What is a Data Collection Rule in Azure?

A DCR defines what monitoring data is collected, how it is processed, and where it is sent.

Q2. What is the relationship between AMA and DCR?

Azure Monitor Agent (AMA) collects data from supported machines. The DCR provides the collection configuration used by the agent.

Q3. Can one DCR be associated with multiple VMs?

Yes. A single DCR can be associated with multiple compatible resources.

Q4. Does a DCR store logs?

No. A DCR configures collection and routing. Logs are stored in destinations such as a Log Analytics Workspace.

Q5. Can a DCR reduce Azure monitoring costs?

Yes. Filtering unnecessary data before ingestion can reduce the volume of billable data, depending on the data source and transformation configuration.

Key point: Remember the relationship:

AMA = Collects monitoring data
DCR = Controls what to collect and where to send
LAW = Stores and queries collected logs
KQL = Queries and analyzes the logs

This is one of the important concepts in Azure Monitor and AZ-104 preparation.

 

 

Azure Data Collection Rule (DCR) – Complete Step-by-Step Practical Guide

In this tutorial, we will create an Azure Data Collection Rule (DCR), associate it with an Azure Virtual Machine, collect Windows Event Logs and performance counters, send them to a Log Analytics Workspace, and verify the collected data using KQL.

We will use the Azure Portal and cover the complete process, including prerequisites, configuration, verification, troubleshooting, and cleanup.

1. What we are going to build

Our practical example uses a Windows Server Virtual Machine running in Azure.

Monitoring architecture

Resources required

Azure resource

Example name

Resource Group

rg-monitoring-demo

Windows Virtual Machine

vm-monitor-demo

Log Analytics Workspace

law-monitor-demo

Data Collection Rule

dcr-windows-monitoring

Azure Monitor Agent

Installed on VM

Prerequisite: You need an Azure subscription, permissions to create and associate monitoring resources, and a running Azure Windows VM. You can reuse an existing VM and resource group instead of creating new ones.

The instructions below assume that the VM and Log Analytics Workspace are in a compatible Azure region.

2. Create a Log Analytics Workspace

A Log Analytics Workspace is the destination where we will store and query the VM's collected monitoring data.

Step 1: Sign in to Azure Portal

Open portal.azure.com and sign in.

Step 2: Search for Log Analytics Workspaces

In the Azure Portal search bar, enter Log Analytics workspaces and select the service.

Step 3: Click Create

On the Log Analytics workspaces page, select Create.

Step 4: Enter workspace details

Use the following example:

Field

Value

Subscription

Your subscription

Resource Group

rg-monitoring-demo

Name

law-monitor-demo

Region

East US

Step 5: Deploy the workspace

Select Review + Create, wait for validation, and click Create.

After deployment succeeds, click Go to resource.

Step 6: Verify the workspace

Open the workspace's Overview page and confirm its name, subscription, resource group, and region.

You now have a destination for collected VM logs.

3. Create the Data Collection Rule

Microsoft's current Azure Portal experience provides a guided DCR creation workflow. Some screens differ between the default and classic experiences.

The screenshots below are illustrative Microsoft documentation images, not screenshots captured from your subscription.

Step 1: Open Data Collection Rules

Navigate to:

Azure Portal → Monitor → Data Collection Rules

Step 2: Select Create

Click Create to open the DCR configuration wizard.

Step 3: Configure the Basics tab

Enter the following values:

Field

Value

Rule name

dcr-windows-monitoring

Subscription

Your subscription

Resource group

rg-monitoring-demo

Region

East US

Platform type

Windows

Type of telemetry (if shown)

Logs and metrics

Select the option for collecting VM guest logs and performance data, rather than the separate platform-metrics export workflow.

Important: Create the DCR in the same region as the destination Log Analytics Workspace. The monitored VM may be in another region, subject to the applicable endpoint and connectivity requirements.

Microsoft Learn
+1

 

4. Associate the Azure VM with the DCR

Step 1: Open the Resources tab

Click Next: Resources.

Step 2: Add your VM

Click Add resources, select the subscription and resource group, and choose:

vm-monitor-demo

Click Apply.

Step 3: Configure the collection endpoint if requested

For supported public-network VM monitoring scenarios, Azure Monitor can use its default endpoints. If the wizard requires a Data Collection Endpoint (DCE), or your deployment uses Azure Monitor Private Link, select or create a compatible endpoint.

Step 4: Understand the agent installation

When you create the DCR and associate it with the VM, Azure can automatically install the Azure Monitor Agent if necessary.

The agent is responsible for collecting the selected guest operating system data.

Step 5: Continue

Click Next: Collect and deliver, or Next: Collect and deliver / Data sources, depending on the wizard version.

Microsoft Learn
+1

 

5. Configure Windows Event Logs

Now we will define exactly which Windows events to collect.

Step 1: Add a data source

Select Add data source or Add new datasource.

Step 2: Choose Windows Event Logs

Set:

Data source type = Windows Event Logs

Step 3: Select log types and severity

For our demonstration, configure:

Windows event log

Severity

Application

Error, Critical

System

Error, Critical

Security

Not selected

This will collect matching Application and System errors, rather than every event.

For initial testing, you may also enable Warning events to increase the chance of receiving sample data.

Step 4: Understand the Custom option

The Custom option allows you to define XPath queries to select events.

For example:

Application!*[System[(Level=1 or Level=2)]]
System!*[System[(Level=1 or Level=2)]]

Windows event levels:

Level

Meaning

1

Critical

2

Error

3

Warning

4

Information

5

Verbose

The example collects Critical and Error events from the Application and System logs.

For beginners, the Basic selection is easier to configure.

Step 5: Set the destination

Choose Azure Monitor Logs and select the Log Analytics Workspace:

law-monitor-demo

In the current wizard, the destination may be configured within the data-source workflow or in a separate Destinations step.

Save the data-source configuration.

The collected Windows events will be stored in the Event table.

Microsoft Learn
+1

 

6. Configure Performance Counters

Next, collect performance measurements from the same VM.

Step 1: Add another data source

On the Collect and deliver page, click Add data source again.

Step 2: Choose Performance Counters

Select:

Data source type = Performance Counters

Collect performance counters with Azure Monitor Agent - Azure Monitor | Azure Docs
 
 
 

Step 3: Select performance counters

For this example, use the Basic selection where available, or Custom to specify the counters below.

Performance counter

Purpose

\Processor(_Total)\% Processor Time

CPU utilization

\Memory\Available MBytes

Available RAM

\LogicalDisk(_Total)\% Free Space

Available disk capacity

Step 4: Configure the sampling rate

Set the sampling frequency to 60 seconds.

This means the agent attempts to collect the configured counter values once per minute.

A shorter sampling interval provides more detailed measurements but can increase data volume.

Step 5: Choose the destination

Select Azure Monitor Logs and choose:

law-monitor-demo

Save the performance-counter data source.

The selected counters will be available in the Perf table in Log Analytics.

Microsoft Learn

 

7. Review and create the DCR

Step 1: Review all configurations

Confirm that your rule contains the following settings:

Configuration

Expected value

DCR

dcr-windows-monitoring

Platform

Windows

Resource

vm-monitor-demo

Data source 1

Windows Event Logs

Data source 2

Performance Counters

Destination

law-monitor-demo

Step 2: Create the rule

Select Review + Create, then Create.

Step 3: Wait for deployment

Azure will create the DCR and its resource association and install the agent if required.

The agent then begins collecting the configured data.

8. Verify Azure Monitor Agent installation

Once deployment is complete, check the agent on your VM.

Step 1: Open the VM

Navigate to:

Azure Portal → Virtual Machines → vm-monitor-demo

Step 2: Open Extensions + applications

Look for:

AzureMonitorWindowsAgent

Step 3: Verify provisioning status

The extension should show a successful provisioning state.

If it failed, open the extension details to inspect the reported error.

Step 4: Verify DCR association

Navigate to:

Monitor → Data Collection Rules → dcr-windows-monitoring → Resources

Confirm that vm-monitor-demo appears in the associated resources.

Note: A successfully provisioned extension does not by itself guarantee successful data ingestion. We must verify the Heartbeat and collected data in Log Analytics.

9. Verify data collection using KQL

Microsoft indicates that data can take up to approximately five minutes to arrive after DCR creation. In some situations, allow additional time for agent provisioning and configuration propagation.

Microsoft Learn

 

Navigate to:

Azure Portal → Log Analytics workspaces → law-monitor-demo → Logs

Step 1: Verify agent communication

Run this query:

Heartbeat
| where TimeGenerated > ago(30m)
| where Computer contains "vm-monitor-demo"
| project TimeGenerated, Computer, OSType
| order by TimeGenerated desc

Expected result: Recent heartbeat records from your VM. An operational agent normally sends a heartbeat approximately every minute.

Step 2: Verify Windows Event Logs

Event
| where TimeGenerated > ago(1h)
| where Computer contains "vm-monitor-demo"
| where EventLevelName in ("Error", "Critical")
| project TimeGenerated,
          Computer,
          EventLog,
          EventID,
          EventLevelName,
          RenderedDescription
| order by TimeGenerated desc

This query retrieves the collected Windows Error and Critical events.

If no events appear, your VM may not have generated any matching events during the selected period.

Step 3: Verify CPU performance

Perf
| where TimeGenerated > ago(1h)
| where ObjectName == "Processor"
| where CounterName == "% Processor Time"
| where InstanceName == "_Total"
| summarize AvgCPU = avg(CounterValue)
    by bin(TimeGenerated, 5m), Computer
| render timechart

This displays average CPU usage over five-minute intervals.

Step 4: Verify memory performance

Perf
| where TimeGenerated > ago(1h)
| where CounterName == "Available MBytes"
| project TimeGenerated, Computer, CounterValue
| order by TimeGenerated desc

This displays the available memory reported by the VM.

Step 5: Verify all collected performance counters

Perf
| where TimeGenerated > ago(1h)
| summarize Records = count()
    by ObjectName, CounterName
| order by Records desc

This helps verify which performance counters are actually being received.

10. Create a test Windows event

If your Windows Event Logs query returns no results, you can generate a test event on the VM.

Connect to the Windows VM using RDP and open PowerShell as Administrator.

Execute:

New-EventLog -LogName Application `
    -Source "DCRDemo"

Then write an Error event:

Write-EventLog `
    -LogName Application `
    -Source "DCRDemo" `
    -EventId 1001 `
    -EntryType Error `
    -Message "Test error generated for Azure DCR monitoring."

Return to Log Analytics and run:

Event
| where TimeGenerated > ago(30m)
| where EventID == 1001
| where Source == "DCRDemo"
| project TimeGenerated,
          Computer,
          EventID,
          RenderedDescription

If the event appears, you have verified the full collection path from Windows Event Log through AMA and DCR to Log Analytics.

11. Troubleshooting common DCR issues

Problem

Possible cause

Solution

No heartbeat records

Agent not installed or unable to communicate

Check extension and network connectivity

No Windows events

Incorrect severity or log selection

Review the Windows Event Logs data source

No CPU data

Performance counter not configured

Review counter selection and sampling interval

VM not associated

DCR association missing

Open DCR → Resources and add the VM

Workspace has no data

Wrong destination or ingestion delay

Check DCR destination and wait for data

DCR creation fails

Permissions or region configuration

Check RBAC permissions and workspace region

For more detailed troubleshooting, refer to Microsoft's Azure Monitor Agent troubleshooting guide.

12. Monitor multiple VMs using one DCR

Once the first VM works, you can associate additional Windows VMs with the same rule.

  VM-01         VM-02         VM-03
    |             |             |
   AMA           AMA           AMA
    |             |             |
    +-------------+-------------+
                  |
                  v
       dcr-windows-monitoring
                  |
                  v
         law-monitor-demo
                  |
          +-------+-------+
          |               |
          v               v
      Event Table      Perf Table
          |               |
          +-------+-------+
                  |
                  v
             KQL Queries

Navigate to:

Monitor → Data Collection Rules → dcr-windows-monitoring → Resources → Add

Select the additional VMs and apply the association.

You do not need to create a separate DCR for every VM when they share the same collection requirements.

13. Monitor ingestion volume and costs

Log Analytics ingestion can incur charges depending on your workspace pricing and data volume.

Use this KQL query to review recent billable ingestion by data type:

Usage
| where TimeGenerated > ago(24h)
| where IsBillable == true
| summarize TotalGB = sum(Quantity) / 1000
    by DataType
| order by TotalGB desc

The Usage table provides ingestion accounting information; its values are not necessarily identical to final invoice amounts.

For cost optimization, collect only necessary logs, avoid unnecessary high-frequency counters, and configure appropriate workspace retention.

14. Clean up the demo resources

If you created these resources only for learning, remove them when you finish.

If rg-monitoring-demo contains only disposable demo resources, you can delete the entire resource group.

Navigate to:

Resource groups → rg-monitoring-demo → Delete resource group

Warning: Deleting a resource group permanently removes its contained resources, including the VM and Log Analytics Workspace. Do not delete a shared or production resource group.

15. Official Microsoft screenshots and references

The following Microsoft Learn articles provide the current portal workflow and embedded screenshots:

Ingest syslog and CEF messages to Microsoft Sentinel - AMA | Microsoft Learn
 
 
 

Collect guest log data from virtual machines

Main practical tutorial covering DCR creation, data sources, resources, destinations, and verification.

 
Collect Windows events from virtual machines with Azure Monitor Agent - Azure Monitor | Microsoft Learn
 
 
 

Collect Windows Event Logs

Portal screenshots and instructions for Windows Event Logs and XPath filtering.

 
Collect performance counters with Azure Monitor Agent - Azure Monitor | Microsoft Learn
 
 
 

Collect Performance Counters

Performance counter configuration, sampling frequency, destinations, and validation.

These official articles are the best references for exact portal screenshots because Azure periodically changes its interface.

16. Final verification checklist

Implementation progress

0 of 10

 
Reset checklist

Final outcome: Your Windows VM sends the selected Event Logs and performance counters through Azure Monitor Agent using a DCR to a Log Analytics Workspace. You can now analyze the data using KQL and create alerts based on collected events or performance thresholds.

← Back to Articles