Monitoring the Snips Environment
Azure Monitor and Log Analytics·50 minutes
Catching problems before users do
The Contractor Document Portal has been running for a month. The Service Desk has started receiving calls about slow performance — but by the time they investigate, the problem has gone. You need to set up proper monitoring so you can see what happened, when it happened, and get alerted before users notice next time.
Azure Monitor is the umbrella service for all monitoring in Azure. Understanding its components — metrics, logs, alerts and workbooks — is essential for operating any Azure environment effectively.
What you will learn
Azure Monitor overview
Azure Monitor collects data from every layer of your Azure environment — infrastructure, applications, operating systems and custom sources. It stores this data in two fundamental data stores: Metrics and Logs.
Metrics
Numerical time-series data collected at regular intervals (typically every minute). Examples: CPU percentage, memory available, disk IOPS. Stored for 93 days by default.
Logs
Structured or unstructured records of events. Examples: Windows Event logs, application traces, sign-in logs. Stored in a Log Analytics workspace.
Diagnostic settings
Configuration that routes resource metrics and logs to a destination: Log Analytics workspace, storage account or Event Hub.
Data collection rules (DCR)
Define what data to collect from VMs and where to send it. Used by the Azure Monitor Agent to configure data collection.
Log Analytics and KQL
Log Analytics is the query interface for log data stored in a Log Analytics workspace. Queries are written in Kusto Query Language (KQL) — a read-only language designed for log analysis. KQL is used across Azure Monitor, Microsoft Sentinel and Microsoft Defender.
|) syntax similar to Unix shell commands. Each pipe passes the result of the previous command to the next. Start with a table name, filter with where, shape with project, aggregate with summarize.Explore these example KQL queries for common Snips monitoring scenarios:
Event
| where EventLevelName == "Error"
| where TimeGenerated > ago(24h)
| project TimeGenerated, Computer, EventLog, RenderedDescription
| order by TimeGenerated desc
| take 100Alerts and action groups
Alert rules monitor a condition and fire when the threshold is met. An action group defines what happens when an alert fires — email, SMS, webhook, Azure Function or ITSM ticket.
Metric alert
Fires when a metric crosses a threshold. Near real-time — evaluates every 1–5 minutes. Best for infrastructure alerts like high CPU or low disk space.
Log alert
Fires when a KQL query returns results. Evaluates on a schedule (minimum 1 minute). Best for application errors, security events and complex conditions.
Activity log alert
Fires when a specific operation is performed in Azure — for example, when a VM is deleted or a resource group is modified.
VM Insights and Workbooks
VM Insights provides pre-built dashboards for VM performance without writing any KQL. Once the Azure Monitor Agent is installed, you get CPU, memory, disk and network charts, plus a map view showing connections between VMs and processes.
Azure Monitor Workbooks are interactive reports that combine metrics, log queries, text and parameters into a single view. They are ideal for operational dashboards, capacity planning reports and incident post-mortems.
Setting up monitoring with Azure CLI
# Create a Log Analytics workspace
az monitor log-analytics workspace create \
--resource-group rg-monitoring-prod-uks-001 \
--workspace-name law-snips-prod-uks-001 \
--location uksouth \
--retention-time 90
# Enable diagnostic settings on a VM (send to Log Analytics)
az monitor diagnostic-settings create \
--name diag-vm-contractordocportal \
--resource "/subscriptions/<sub-id>/resourceGroups/rg-compute-prod-uks-001/providers/Microsoft.Compute/virtualMachines/vm-contractordocportal-prod-uks-001" \
--workspace law-snips-prod-uks-001 \
--metrics "[{"category":"AllMetrics","enabled":true}]"
# Create an alert rule for high CPU
az monitor metrics alert create \
--name alert-vm-highcpu \
--resource-group rg-monitoring-prod-uks-001 \
--scopes "/subscriptions/<sub-id>/resourceGroups/rg-compute-prod-uks-001/providers/Microsoft.Compute/virtualMachines/vm-contractordocportal-prod-uks-001" \
--condition "avg Percentage CPU > 85" \
--window-size 5m \
--evaluation-frequency 1m \
--action ag-snips-ops-alerts- 1.Create a Log Analytics workspace in UK South with 90-day retention.
- 2.Install the Azure Monitor Agent on the Contractor Document Portal VM.
- 3.Enable VM Insights and view the performance dashboard.
- 4.Create an alert rule that fires when CPU exceeds 85% for 5 minutes.
- 5.Create an action group that sends an email to your address.
- 6.Run a KQL query in Log Analytics to find the last 50 events from the VM.
1.The Contractor Document Portal VM is responding slowly. Which Azure Monitor feature would you use to view CPU and memory usage over the past 24 hours?
2.You want to query the last 100 errors from the Contractor Document Portal application logs. Which tool and language do you use?
3.Snips wants to receive an email when the VM CPU exceeds 85% for more than 5 minutes. What do you configure?
4.Which Azure Monitor feature provides pre-built dashboards for VM performance including CPU, memory, disk and network, without writing any KQL?
5.A developer asks you to enable monitoring for the Snips internal API to track request rates, response times and failures. Which service should you configure?
Module summary
The Snips environment now has proper monitoring. You have a Log Analytics workspace collecting data from the VM, alerts configured for critical conditions and VM Insights providing performance dashboards. Problems will now be caught before users notice them.
Ready to mark this module complete?
Mark complete when you have read all sections, attempted the lab and completed the knowledge check.
- Monitor and maintain Azure resources