How to Configure or Scale Log Caching DCR in Azure Monitor Agent for Microsoft Sentinel

📘 Introduction

If you’re using Azure Monitor Agent (AMA) for collecting logs from virtual machines, it’s important to understand the concept of log caching using Data Collection Rules (DCRs).

In this blog, you’ll learn:

  • What Log Caching in AMA is
  • When and why it’s needed
  • Default vs. extended caching limits (up to 1 TB)
  • AMA versions that support this feature
  • How to plan and size it for your environment
  • Step-by-step setup with screenshots and code

💡 What is Log Caching in Azure Monitor Agent?

Azure Monitor Agent collects logs and metrics from your Azure VMs and forwards them to Log Analytics. But what happens when there’s no network or temporary disruption?

This is where log caching comes in.

When you configure an AgentSettings DCR, AMA will cache logs locally on the machine if it’s unable to send them immediately. It will then forward the cached data once connectivity is restored.


🛠️ Why and When is Log Caching Required?

Log caching is critical in scenarios such as:

  • Network or Azure region outages
  • 🧩 On-premises or hybrid VMs with unreliable internet
  • 📈 High ingestion bursts that cause backlog

By default, AMA buffers up to 10 GB of logs for ~72 hours. But in some environments, that’s just not enough.


📏 Default Cache Limit vs. 1 TB Expansion

TypeLimitSupported AMA Version
Default10,000 MB (10 GB)All
ExtendedUp to 1,000,000 MB (1 TB)Windows ≥ 1.34.0
Linux ≥ 1.34.5

Note: This feature is currently in preview and requires configuring a special AgentSettings DCR via ARM templates or CLI. Portal support is limited.


🧮 How to Plan Log Caching for Your Environment

Before enabling large cache limits, calculate:

Cache Needed (MB) = Event Rate × Event Size × Duration

Example:

  • Event rate: 5,000 events/sec
  • Avg. size: 200 bytes
  • Outage duration: 24 hours

Total ≈ 5,000 × 200 × 86400 = 86.4 GB

💡 Tip: Leave a margin (10–15%) for overhead and unexpected spikes.

Also ensure:

  • Enough free disk space on the AMA cache path:
    • Windows: C:\ProgramData\Azure Monitor Agent\
    • Linux: /var/opt/microsoft/azuremonitoragent/

🧰 How to Create a Log Caching DCR (Step-by-Step)

This example sets the cache to 500 GB.

1️⃣ Prepare JSON Template

{
  "type": "Microsoft.Insights/dataCollectionRules",
  "name": "dcr-logcache-example",
  "apiVersion": "2023-03-11",
  "kind": "AgentSettings",
  "location": "eastus",
  "properties": {
    "description": "Increase offline log cache to 500 GB",
    "agentSettings": {
      "logs": [
        { "name": "MaxDiskQuotaInMB", "value": "500000" }
      ]
    }
  }
}

2️⃣ Deploy DCR via Azure CLI

az monitor data-collection rule create \
  --resource-group rg-name \
  --name dcr-logcache-example \
  --location eastus \
  --kind AgentSettings \
  --body @log-cache-dcr.json

3️⃣ Associate DCR to VM

az monitor data-collection rule association create \
  --name agentSettingsAssoc \
  --rule-id /subscriptions/xxxx/resourceGroups/rg-name/providers/Microsoft.Insights/dataCollectionRules/dcr-logcache-example \
  --resource /subscriptions/xxxx/resourceGroups/rg-name/providers/Microsoft.Compute/virtualMachines/vm-name

4️⃣ Restart AMA Agent (Optional)

  • Windows: net stop AzureMonitorAgent && net start AzureMonitorAgent
  • Linux: sudo systemctl restart azuremonitoragent

🛠️ Troubleshooting Tips

IssueResolution
Log cache not workingCheck AMA version (must be ≥ 1.34.x)
Disk fullExpand partition that stores the AMA cache
Cache not appliedEnsure only one AgentSettings DCR per VM
No data uploaded after reconnectionLogs upload from (now – 1 hour), expect slight delay

🧾 Summary

🔹 Log caching via AgentSettings DCR makes AMA more resilient.
🔹 Helps prevent data loss during outages or disconnections.
🔹 Default limit is 10 GB, extendable up to 1 TB.
🔹 Requires Azure Monitor Agent v1.34+.
🔹 Must be created via ARM or CLI (portal support is limited for AgentSettings).


📣 Call to Action

💬 Have questions or want to automate your Azure Monitor deployments?
📧 Reach out or drop a comment below!

🔗 Bookmark secbyte.in for more Microsoft Sentinel and Azure security blogs.

Responses to “How to Configure or Scale Log Caching DCR in Azure Monitor Agent for Microsoft Sentinel”

  1. Shubham Lale

    Hi Sujit,

    Thank you for insightful blog, Your configuration insights are much appreciated.

    I have a couple of suggestions to improve the blog:

    1. Clarification on the Cache Calculation Formula

    In the section “How to Plan Log Caching for Your Environment”, the formula is currently stated as:

    Cache Needed (MB) = Event Rate × Event Size × Duration

    To avoid confusion, it would be helpful to specify that Duration should be in seconds. This ensures accurate cache size estimation.

    2. Validation Steps After Configuration

    It would also be beneficial to include a note on how to validate the configuration after making changes. While there isn’t a direct method to verify the changes within the Azure portal, validation can be performed at the server level. Here are the recommended steps:

    • Check the Azure Monitor Agent logs on the VM for errors related to applying the DCR or setting the cache size.
      The logs can be found at:
      • Windows:
        C:Program FilesMicrosoft Monitoring AgentAgentHealth Service State
      • Linux:
        /var/opt/microsoft/azuremonitoragent/events

    Liked by 1 person

    1. Thanks for adding value subham

      Like

Leave a comment