You cannot fix what you cannot see. Azure Monitor is the built-in observability platform for Azure: it collects metrics and logs from every resource, lets you query them with KQL, and fires alerts before small problems become outages. This guide shows a sysadmin how to set up Azure Monitor for Linux VMs, write first queries, and create CPU and availability alerts. This article covers Azure Monitor Basics in detail.
Azure Monitor Building Blocks – Azure Monitor Basics
- Metrics — lightweight numeric time series (CPU %, disk bytes, network in/out) stored for 93 days, available almost in real time.
- Logs — rich records sent to a Log Analytics workspace: syslog, performance counters, heartbeat data from agents.
- Alerts — rules evaluated against metrics or log queries that trigger action groups (email, SMS, webhook, automation runbook).
- Activity log — the control-plane audit trail of who created, changed or deleted resources.
If you are coming from self-hosted tooling, Azure Monitor plays the role that our Netdata monitoring setup or Zabbix server plays on-prem — except it is already wired into every Azure service.
Prerequisites – Azure Monitor Basics
- An Azure VM to monitor and Azure CLI signed in
- Permissions to create a Log Analytics workspace (Log Analytics Contributor is sufficient)
Step 1: Create a Log Analytics Workspace
az monitor log-analytics workspace create \
--resource-group rg-linux-prod \
--workspace-name law-prod-01 \
--location eastus
Step 2: Connect the VM with the Azure Monitor Agent
The modern Azure Monitor Agent (AMA) replaces the legacy Log Analytics agent. Enable VM insights, which installs the agent and starts collecting performance data:
az vm extension set \
--resource-group rg-linux-prod \
--vm-name vm-web-01 \
--name AzureMonitorLinuxAgent \
--publisher Microsoft.Azure.Monitor
Data collection rules in the portal then decide which syslog facilities and performance counters flow into your workspace.

Step 3: Query Logs with KQL
Kusto Query Language powers every log search in Azure Monitor. Two starter queries:
// Which machines reported in during the last hour?
Heartbeat
| where TimeGenerated > ago(1h)
| summarize LastSeen = max(TimeGenerated) by Computer
// Average CPU per machine, 5-minute buckets
Perf
| where CounterName == "% Processor Time"
| summarize avg(CounterValue) by Computer, bin(TimeGenerated, 5m)
Run them in the portal under Logs, or from scripts with az monitor log-analytics query --workspace <workspace-id> --analytics-query "Heartbeat | take 5".
Step 4: Create a Metric Alert with Azure Monitor
First an action group (who gets notified), then the alert rule itself:
az monitor action-group create \
--resource-group rg-linux-prod \
--name ag-sysadmins \
--short-name sysadmins \
--action email oncall [email protected]
VM_ID=$(az vm show --resource-group rg-linux-prod --name vm-web-01 --query id --output tsv)
az monitor metrics alert create \
--name alert-high-cpu \
--resource-group rg-linux-prod \
--scopes $VM_ID \
--condition "avg Percentage CPU > 80" \
--window-size 5m \
--evaluation-frequency 1m \
--action ag-sysadmins \
--description "CPU above 80 percent for 5 minutes"
Pair metric alerts with an availability test or a log alert on application errors for coverage of both “the server is struggling” and “the service is down”. The Azure Monitor overview on Microsoft Learn maps all data sources and retention options.
Dashboards, Availability Tests and Log Costs
Three additions round out a monitoring setup. Dashboards pin your most-used metric charts and log queries to one page — build a single “morning check” view per application so the first five minutes of every incident start from the same picture. Availability tests in Application Insights ping your public URLs from Azure locations worldwide every few minutes and alert when the site is down or slow for users, catching DNS, certificate and ISP problems that internal metrics never see. And keep an eye on log costs: ingestion is billed per gigabyte, and a verbose application can silently become the most expensive line item. Set a daily cap on non-production workspaces, route noisy tables to the cheaper Basic Logs tier, and archive older data to storage instead of deleting the habit of logging altogether.
Keeping Alerts Useful: Tuning and Alert Fatigue
An alerting system that cries wolf gets ignored, so treat thresholds as living configuration. Start with the CPU rule above, then review fired alerts monthly: any alert that fires weekly without action needed is either too sensitive or pointing at a real capacity problem to fix permanently. Use alert processing rules to suppress notifications during planned maintenance windows instead of letting the team learn to ignore the channel. Group related signals — one alert for “VM CPU high” is helpful; five alerts for CPU, memory, disk latency and two downstream symptoms of the same event is noise. Finally, write the first response step into each alert’s description (“check top processes, then the deployment history”), so a 3 a.m. notification arrives with its own runbook attached.
Troubleshooting
- No data in the workspace: confirm the agent extension shows “provisioning succeeded”, then check that a data collection rule is associated with the VM. Heartbeats appear within about 10 minutes.
- Alert never fires: verify the rule is enabled, the metric namespace matches (guest metrics need the agent; host metrics do not), and the evaluation window actually overlaps the spike.
- Unexpected Log Analytics bills: log ingestion is charged per GB. Use the Usage and estimated costs blade to find chatty tables and trim data collection rules.
Conclusion
Azure Monitor centralizes metrics, logs and alerting for everything you run in Azure. Set up a workspace, connect your VMs with the Azure Monitor Agent, learn a handful of KQL patterns, and wire CPU and availability alerts to an action group — that foundation catches the majority of production incidents before your users do.