You, the admin: start collecting logs properly
- Create one Log Analytics workspace per environment: Log Analytics workspaces › + Create, name LAW-Prod, region same as most resources. Under Usage and estimated costs › Data retention set 90 days (default 30; up to 2 years interactive, then archive to 12 years). You pay per GB ingested.
- Keep the Activity log longer than 90 days: Monitor › Activity log › Export Activity Logs › + Add diagnostic setting, tick all categories, destination LAW-Prod.
- Get logs from inside a resource: Storage account (or Key Vault, NSG…) › Diagnostic settings › + Add, pick log categories and metrics, destination workspace (to query), storage account (cheap archive) or Event Hub (to a SIEM).
- Get Windows event logs and performance counters from VMs: Monitor › Data Collection Rules › + Create, add the VMs as resources, choose Windows Event Logs / Performance counters / Syslog, destination LAW-Prod. This installs the Azure Monitor Agent on each VM for you. (The old Log Analytics agent is retired.)
Asking questions of the logs
Workspace › Logs uses KQL. You will read it, not write it from scratch:
Heartbeat // table: one row per agent check-in
| where TimeGenerated > ago(1h) // last hour only
| summarize count() by Computer // group and count
| order by count_ desc // biggest first
Tables to recognise: Heartbeat (agent alive), Perf (counters), Event (Windows events), Syslog, AzureActivity, AzureDiagnostics, AzureMetrics, StorageBlobLogs. Operators: where, summarize, project, extend, join, top, render.
Alerts
How an alert reaches a person
- Signal and conditionWhich metric or log query, and the threshold: average CPU above 85% for 5 minutes.
- Alert rule firesScoped to a resource or group, with a severity 0 (critical) to 4.
- Action group runsA reusable list: email, SMS, push, voice, runbook, Function, Logic App, webhook. Create once, attach to many rules.
- Alert processing rule may interveneAt a scope it can add action groups in bulk or suppress notifications on a schedule, while alerts keep being recorded.
You, the admin: email ops when VM1's CPU stays above 85%
- Make the action group first: Monitor › Alerts › Action groups › + Create, name AG-Ops, notification Email = [email protected] (also SMS, push to the Azure app, voice; and actions: Automation runbook, Function, Logic App, webhook, ITSM, Event Hub).
- Monitor › Alerts › + Create › Alert rule. Scope: VM1. Condition: signal Percentage CPU, aggregation Average, operator greater than, threshold 85, check every 1 min, lookback 5 min. (Or tick Dynamic threshold and let Azure learn normal.)
- Actions: AG-Ops. Details: severity 2, name, enable on create. Metric alerts auto-resolve when the condition clears.
- Maintenance window: Alerts › Alert processing rules › + Create, scope RG-Prod, rule type Suppress notifications, recurring Saturday 02:00 to 04:00. Alerts still fire and show in history; nobody gets paged.
| Signal type | Example | Note |
|---|---|---|
| Metric | CPU, disk queue, HTTP 5xx count | Near real time, cheapest, auto-resolves |
| Log search | KQL returns rows (failed logons > 10) | Runs every 5 to 60 min |
| Activity log | Any VM deleted; Service Health incident; Resource Health change | Management events |
Insights are ready-built dashboards: VM insights (performance + a map of which process talks to which port), Storage insights, Network insights, Container insights, Application Insights for code. All built on Workbooks, which you can also edit and pin to a shared dashboard.