Home › Studies › AZ-104 › Monitor & Maintain › Azure Monitor

Azure Monitor

Metrics · diagnostic settings · Log Analytics workspaces · Azure Monitor Agent · KQL

By the tools4free.dev team · Last reviewed November 13, 2026

Practice questions for this topic →

Metrics and logs

MetricsLogs
What it isNumeric time seriesRecords stored in tables, collected and queried with a query language (KQL)
Platform dataCollected automatically from Azure resources, no configuration. Frequency is one minute unless the metric says otherwiseThe activity log is collected automatically. Resource logs are not collected until you create a diagnostic setting
Retention93 days for platform and custom metrics. One chart in Metrics explorer can query at most 30 days; select 30 days, then pan to see the rest of the 93Set per table. Each table can keep data up to 12 years. Search jobs bring long-term data back to interactive
CostNo ingestion or storage charge for platform metricsNo direct cost to create a workspace. You pay for ingestion and retention per table plan

Moving or renaming an Azure resource can lose its metric history. To trend metrics for longer than 93 days, send them to a Log Analytics workspace with a diagnostic setting.

Host data vs guest data

Diagnostic settings

ItemRule
SendsResource logs, platform metrics or the activity log
DestinationsLog Analytics workspace, Storage account, Event Hubs, partner solutions
Settings per resource5
Destinations of the same type per setting1. Create another setting for another workspace, storage account or event hub
Destination must existBefore you create the setting. Log Analytics tables are created automatically when the first data arrives
RegionFor regional resources, the Storage account and Event Hubs destination must be in the same region as the monitored resource
Storage account typeStandard accounts only. Premium accounts and accounts with DNS zone endpoints are not supported
Storage or event hub with a firewall or VNetTurn on Allow trusted Microsoft services to bypass this firewall
Event Hubs permissionsManage, Send and Listen on the namespace authorization rule. Updating the setting needs ListKey
Other subscription or tenantAnother subscription works if you have RBAC access to both. For another Microsoft Entra tenant, use Azure Lighthouse
TimingData should start flowing within 90 minutes. If nothing arrives after 24 hours, there is a problem

Log Analytics workspace and queries

KQL examples

QueryWhat it returns
SecurityEvent | take 1010 arbitrary rows, in no particular order. Good for seeing the table shape
SecurityEvent | top 10 by TimeGeneratedThe 10 latest rows. top sorts on the server; descending is the default
SecurityEvent | where Level == 8 and EventID == 4672Only rows that match both conditions. == is case-sensitive; =~ is case-insensitive
SecurityEvent | where TimeGenerated > ago(30m) | where toint(Level) >= 10Rows from the last 30 minutes with Level of 10 or more. Level is a string, so cast it with toint. ago units include m, d and s
SecurityEvent | top 10 by TimeGenerated | project TimeGenerated, Computer, ActivityOnly the three listed columns. project selects or renames columns
SecurityEvent | top 10 by TimeGenerated | extend EventCode=substring(Activity, 0, 4)All original columns plus one new computed column. extend keeps all columns
Perf | where TimeGenerated > ago(1h) | summarize count() by ObjectNameOne row per ObjectName with the number of Perf records in the last hour
Perf | where TimeGenerated > ago(1h) | summarize avg(CounterValue) by Computer, CounterNameThe average per computer and counter. Group by both so the values are meaningful
Perf | where TimeGenerated > ago(7d) | where Computer == "DC01.na.contosohotels.com" | where CounterName == "Available MBytes" | summarize avg(CounterValue) by bin(TimeGenerated, 1h)Hourly average free memory for a week. bin buckets continuous values. Switch to Chart view to see a time chart
search in (SecurityEvent) "Cryptographic" | take 1010 rows where any column contains the phrase. Slower than a table-based where filter
Perf | where TimeGenerated > ago(7d) | where CounterName == "Available MBytes" | summarize avg(CounterValue) by bin(TimeGenerated, 1h) | render timechartThe hourly averages drawn as a time chart. render must be the last operator

CLI and PowerShell

TaskAzure CLIPowerShell
Create a resource diagnostic settingaz monitor diagnostic-settings create --name N --resource <id> --logs '[{"category":"AuditEvent","enabled":true}]' --metrics '[{"category":"AllMetrics","enabled":true}]' --workspace <id>New-AzDiagnosticSetting -Name N -ResourceId <id> -WorkspaceId <id> -Log $log -Metric $metric
Export the activity logaz monitor diagnostic-settings subscription create (or update)Not supported with New-AzDiagnosticSetting; use an ARM template
Use resource-specific tablesAdd --export-to-resource-specific trueNot covered on the page
Install Azure Monitor Agent on a Windows VMaz vm extension set --name AzureMonitorWindowsAgent --publisher Microsoft.Azure.Monitor --vm-name VM --resource-group RGNot covered on the page
Associate a DCR with a VMaz monitor data-collection rule association create --name A --rule-id <dcr> --resource <vm id>New-AzDataCollectionRuleAssociation -AssociationName A -ResourceUri <vm id> -DataCollectionRuleId <dcr>
Read metricsaz monitor metrics command groupAz.Monitor module cmdlets

Exam Tips

Tick each tip once you can answer it without looking.

“Archive a resource's logs in a storage account” → Diagnostic setting to a Standard storage account. Trap: Premium storage accounts aren't supported as a destination.

“Stream resource logs to a third-party SIEM” → Diagnostic setting to Event Hubs. Trap: A storage account is a static store, not a stream.

“Diagnostic setting to a storage account in another region fails” → For a regional resource the storage account must be in the same region. Trap: Any region works.

“Diagnostic setting can't write to a storage account that has a firewall” → Turn on Allow trusted Microsoft services to bypass this firewall.

“Send one resource's logs to two Log Analytics workspaces” → Two diagnostic settings. Trap: A setting takes one destination of each type.

“A sixth diagnostic setting on one resource” → Not possible: the limit is 5 per resource. Trap: The limit is per resource, not per subscription.

“Export the subscription activity log with the CLI” → az monitor diagnostic-settings subscription create. Trap: New-AzDiagnosticSetting can't export the activity log; use an ARM template.

“No data 24 hours after creating a diagnostic setting” → Something is wrong: data should start within 90 minutes.

“Resource logs aren't showing up in a workspace” → Create a diagnostic setting. Trap: Only the activity log and platform metrics are collected automatically.

“Metrics chart is blank at a 90-day range” → A chart spans at most 30 days: pick 30 days and pan within the 93-day retention. Trap: Metrics are kept 93 days, not 30.

“Metric history disappeared after renaming a resource” → Expected: moving or renaming a resource can lose metric history. Trap: It isn't a retention setting.

“Collect Windows event logs and Syslog from VMs” → Azure Monitor Agent plus a data collection rule, sent to a Log Analytics workspace. Trap: Diagnostic settings route platform data from a resource; the Log Analytics agent was retired in August 2024.

“Guest memory metrics are missing for a VM” → Enable guest monitoring (Azure Monitor Agent). Trap: Host metrics give overall performance and load (CPU, network traffic, disk I/O), not guest data.

“Recreated a VM with the same name and logs flow again” → The old diagnostic setting was never deleted: delete settings when you delete, rename or move a resource. Trap: Settings don't disappear with the resource.

“A user must read workspace data but not change it” → Log Analytics Reader (provides Microsoft.OperationalInsights/workspaces/query/*/read).

“Show only the Computer and Activity columns” → project. Trap: extend keeps all columns and adds more.

“Get the 10 latest rows” → top 10 by TimeGenerated. Trap: take 10 returns arbitrary rows in no particular order.

“Show hourly averages as a time chart” → | summarize ... by bin(TimeGenerated, 1h) | render timechart. Trap: render must be the last operator, so it can't come before summarize.

Sources

Checked against Microsoft Learn on November 13, 2026.

← Monitor & Maintain overviewAlerts & Action Groups →