Microsoft Docs

Azure Virtual Machine Diagnostics

Diagnostics for Azure Virtual Machines provides real‑time insight into the health and performance of your VMs. It captures metrics, logs, and crash dumps to help you troubleshoot issues faster.

Table of Contents ▼

Overview

The Diagnostics extension runs inside the VM and streams performance counters, event logs, and custom logs to an Azure Storage account or Log Analytics workspace.

Prerequisites

Enable Diagnostics Extension

You can enable the extension via Azure Portal, Azure CLI, or PowerShell. Below is an Azure CLI example:

az vm extension set \
  --publisher Microsoft.Azure.Diagnostics \
  --name LinuxDiagnostic \
  --resource-group MyResourceGroup \
  --vm-name MyLinuxVM \
  --settings '{"storageAccount":"mydiagstorage"}'

Configuration Settings

Configure the extension using a JSON settings file. The most common sections are metrics, logs, and performanceCounters.

Collecting Data

Once enabled, the extension uploads data according to the schedule defined in the config. To view the data:

  1. Navigate to the Azure Storage account → Containers → diagnostics-<vmname>.
  2. Or open Log Analytics and run queries against the Heartbeat and Perf tables.

Best Practices

Sample Configuration File

{
  "storageAccount": "mydiagstorage",
  "storageAccountKey": "REDACTED",
  "metrics": {
    "resourceId": "/subscriptions/xxxx/resourceGroups/MyRG/providers/Microsoft.Compute/virtualMachines/MyVM",
    "interval": "PT1M",
    "performanceCounters": [
      {
        "counterSpecifier": "\\Processor(_Total)\\% Processor Time",
        "sampleRate": "PT1M",
        "unit": "Percent"
      },
      {
        "counterSpecifier": "\\Memory\\Available Mbytes",
        "sampleRate": "PT1M",
        "unit": "Megabytes"
      }
    ]
  },
  "logs": {
    "syslog": {
      "facilityNames": ["auth","authpriv","daemon"],
      "logLevel": "INFO",
      "schedule": { "frequency": "PT5M" }
    }
  }
}

FAQ

How often does the extension upload data?

Can I disable diagnostics for a specific VM?

What are the costs associated with diagnostics?