Home Microsoft AzureAzure Monitor Alerts for Linux VMs: Complete Setup Guide

Azure Monitor Alerts for Linux VMs: Complete Setup Guide

by Knowledge Base Linux
azure monitor alerts dashboard watching a Linux virtual machine

Most Linux VM outages announce themselves long before they happen: CPU creeps upward, disk space drains steadily, memory pressure builds over days. The difference between a quiet fix and a 2 a.m. incident is whether anyone was watching. Azure Monitor alerts turn those early signals into notifications, so you act while the problem is still small. In this guide you will enable monitoring on a Linux VM, build alert rules for the metrics that matter, and route notifications to the people who can act.

Azure Monitor collects two kinds of data: metrics, which are numbers sampled over time such as CPU percentage, and logs, which are detailed records you can query. Alert rules watch either kind and fire when a condition holds for a defined period. The action group decides what happens next: an email, an SMS, a webhook to your incident tool, or an automation runbook.

azure monitor alerts sending a notification when a metric crosses a threshold

How Azure Monitor Alerts Work for Linux VMs

Platform metrics such as CPU percentage and network throughput are collected automatically for every VM, no agent required. Guest operating system metrics such as disk usage and memory require the Azure Monitor Agent and a data collection rule, because the hypervisor cannot see inside the guest. Once metrics flow into a Log Analytics workspace or the metrics store, an alert rule evaluates them on a schedule, and when the threshold condition is met for the full evaluation window, it fires the action group exactly once per incident, not once per evaluation.

The key design choices are the threshold, the evaluation window, and the severity. A CPU alert at 90 percent sustained for 15 minutes catches real saturation while ignoring brief compile spikes. A disk alert at 85 percent full gives you time to clean up before the filesystem fills. Severity decides who gets woken up: reserve Sev 0 and Sev 1 for customer impact, and use Sev 2 or lower for warnings.

Prerequisites

  • An Azure subscription with a Linux VM already running.
  • Azure CLI installed and logged in, or access to the Azure portal.
  • A Log Analytics workspace, or permission to create one.
  • An email address or webhook endpoint for notifications.

Step 1: Enable the Azure Monitor Agent on the VM

Install the agent and associate a data collection rule so guest metrics flow into your workspace:

az vm extension set   --resource-group my-rg   --vm-name my-linux-vm   --name AzureMonitorLinuxAgent   --publisher Microsoft.Azure.Monitor   --version 1.0

az monitor data-collection-rule association create   --resource "/subscriptions/<sub-id>/resourceGroups/my-rg/providers/Microsoft.Compute/virtualMachines/my-linux-vm"   --rule "/subscriptions/<sub-id>/resourceGroups/my-rg/providers/Microsoft.Insights/dataCollectionRules/my-dcr"

Verify data is flowing by checking the VM Insights performance view in the portal. If the charts are empty after 15 minutes, the data collection rule is the usual suspect: confirm it targets the VM and includes the performance counters you need.

Step 2: Create Azure Monitor Alerts for CPU and Disk

Create an action group first, then an alert rule that uses it. With the CLI, an action group with an email receiver looks like this:

az monitor action-group create   --resource-group my-rg   --name ops-team   --short-name ops   --action email oncall [email protected]

Then create a metric alert that fires when average CPU exceeds 85 percent for 15 minutes:

az monitor metrics alert create   --resource-group my-rg   --name high-cpu-linux-vm   --scopes "/subscriptions/<sub-id>/resourceGroups/my-rg/providers/Microsoft.Compute/virtualMachines/my-linux-vm"   --condition "avg Percentage CPU > 85"   --window-size 15m   --evaluation-frequency 5m   --action ops-team   --severity 2   --description "Linux VM CPU above 85 percent"

Repeat the pattern for disk space using the guest metric for logical disk free space, and for memory using available memory bytes. Three well-chosen alerts beat twenty noisy ones.

Step 3: Test Alerts and Tune Out Noise

Trigger a test by running a CPU stress tool on the VM for a few minutes, or temporarily lower the threshold to a value the current load already exceeds. Confirm the notification arrives, the alert appears in the portal, and it auto-resolves when the metric recovers. Then tune: if an alert fires every Monday during backups, add a suppression window or raise the threshold, because an alert the team learns to ignore is worse than no alert at all.

Troubleshooting Azure Monitor Alerts

No data in the charts. The agent may be installed but the data collection rule may not be associated, or the workspace may be in a different region. Check the agent status with az vm extension show and the association in the portal.

Alert never fires. Confirm the metric name matches exactly, the scope points at the VM and not the resource group, and the window and threshold combination is actually reached. A 15-minute window with a 90 percent threshold will not fire on a 10-minute spike.

Too many notifications. One firing per incident is normal, but repeated firings mean the metric is flapping around the threshold. Widen the window, add a second condition, or fix the underlying load problem instead of silencing the alert.

Notifications go to the wrong people. Action groups are shared across rules, so editing one affects every rule using it. Create separate action groups for on-call engineers and for informational mailing lists.

Conclusion

With Azure Monitor alerts in place, your Linux VMs tell you about problems while they are still fixable: CPU saturation, disk pressure, and memory exhaustion arrive as notifications instead of user complaints. Keep the rule set small, tune thresholds against real load, and review fired alerts monthly to prune noise. For more Azure practice, see our guides on Azure Blob Storage tiers and Azure Bastion for Linux VMs. The official reference is Azure Monitor alerts documentation.

You may also like

KbLinux

Typically replies within a day

Hello, Welcome to the site. Please click below button for chatting me through Telegram.