Azure Monitor: metrics, logs and insights
Understand what Azure collects automatically, what you must switch on, and where each kind of data goes.
In this lesson you'll learn
- Metrics versus logs, and the activity log
- Diagnostic settings for resource logs
- Azure Monitor Agent and data collection rules for VMs
- Insights for VMs, storage and networks
1. Two kinds of data
New to monitoring? Start here
Monitoring answers three questions: Is it healthy? What happened? Who changed it? Azure Monitor is the single service that collects the data to answer all three, for everything in Azure and for servers elsewhere.
| Item | Metrics | Logs |
|---|---|---|
| Shape | Numbers at regular intervals (CPU %, requests) | Records with many fields (events, errors, sign-ins) |
| Speed | Near real time | A few minutes delay |
| Kept | 93 days | Set per workspace, up to 12 years in total |
| Explore with | Metrics Explorer | KQL in Log Analytics |
2. The activity log
The activity log records control plane events across the subscription: who created, changed, deleted, started or deallocated what, and when. It also shows Service Health events. It is kept for 90 days. Send it to a workspace to keep it longer or query it with KQL.
Exam focus
"Notify me when a VM is deallocated" or "who deleted this resource" means the activity log. Metrics cannot tell you who did something.
3. Diagnostic settings
Resource logs, such as Key Vault access logs or storage read requests, are not collected until you add a diagnostic setting on the resource.
| Destination | Use it to |
|---|---|
| Log Analytics workspace | Query with KQL and alert on logs |
| Storage account | Archive cheaply for audits |
| Event Hubs | Stream to a SIEM or third-party tool |
| Partner solution | Send to supported monitoring partners |
4. Monitoring inside VMs
Azure sees a VM's host metrics, like CPU, but not what happens inside the operating system. For guest event logs, syslog and performance counters:
- Create a Log Analytics workspace.
- Create a data collection rule (DCR) that says what to collect (for example System and Application errors) and where to send it.
- The Azure Monitor Agent is installed on each VM associated with the rule. One agent can send to several workspaces.
Insights are ready-made monitoring views: VM Insights (performance and a dependency map), Storage Insights, Network Insights and Container Insights.
Example
SS Kaiser's app server keeps freezing at night, but CPU metrics look normal. The team creates a DCR that collects Application event log errors from the VM into their workspace. The next morning, a KQL query shows a disk-full error from the backup software at 2 am every night.
Exam traps to remember
- The legacy Log Analytics agent (MMA) is retired. Use Azure Monitor Agent.
- Resource logs need a diagnostic setting. Platform metrics do not.
- Guest OS events need a workspace and DCR. They are not VM metrics.
Test yourself: 3 check questions and exam-style practice questions on this topic are in the AZ-104 Azure Administrator app.
Practise in the app