2020-02-10 21:12:57 -05:00
---
lab:
2023-06-12 15:30:55 -07:00
title: 'Lab 11: Implement Monitoring'
2022-09-01 13:02:28 -07:00
module: 'Administer Monitoring'
2020-02-10 21:12:57 -05:00
---
# Lab 11 - Implement Monitoring
2024-02-23 07:32:32 -08:00
## Lab introduction
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
In this lab, you learn about Azure Monitor. You learn to create an alert and send it to an action group. You trigger and test the alert and check the activity log.
2022-08-31 14:56:01 -07:00
2024-02-23 07:32:32 -08:00
This lab requires an Azure subscription. Your subscription type may affect the availability of features in this lab. You may change the region, but the steps are written using **East US** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Estimated timing: 40 minutes
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Lab scenario
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
Your organization has migrated their infrastructure to Azure. It is important that Administrators are notified of any significant infrastructure changes. You plan to examine the capabilities of Azure Monitor, including Log Analytics.
2020-05-01 10:08:43 -07:00
2024-02-23 07:32:32 -08:00
## Architecture diagram
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00

2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Job skills
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
+ Task 1: Use a template to provision an infrastructure.
+ Task 2: Create an alert.
+ Task 3: Configure action group notifications.
+ Task 4: Trigger an alert and confirm it is working.
+ Task 5: Configure an alert processing rule.
+ Task 6: Use Azure Monitor log queries.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Task 1: Use a template to provision an infrastructure
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
In this task, you will deploy a virtual machine that will be used to test monitoring scenarios.
2020-02-10 21:12:57 -05:00
2024-03-10 10:37:27 -07:00
1. Download the ** \\Allfiles\\Lab11\\az104-11-vm-template.json** lab files to your computer.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Sign in to the **Azure portal** - `https://portal.azure.com` .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. From the Azure portal, search for and select `Deploy a custom template` .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. On the custom deployment page, select **Build you own template in the editor** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. On the edit template page, select **Load file** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Locate and select the ** \\Allfiles\\Labs11\\az104-11-vm-template.json** file and select **Open** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Save** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Use the following information to complete the custom deployment fields, leaving all other fields with their default values:
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
| Setting | Value |
| --- | --- |
| Subscription | Your Azure subscription |
| Resource group| `az104-rg11` (If necessary, select **Create new** )
| Region | **East US** |
| Username | `localadmin` |
| Password | Provide a complex password |
2023-04-07 12:13:14 -07:00
2024-02-23 07:32:32 -08:00
1. Select **Review + Create** , then select **Create** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Wait for the deployment to finish, then click **Go to resource group** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Review what resources were deployed. There should be one virtual network with one virtual machine.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
**Configure Azure Monitor for virtual machines (this will be used in the last task)**
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. In the portal, search for and select **Monitor** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Take a minute to review all the insights, detection, triage, and diagnosis tools that are available.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **View** in the **VM Insights** box, and then select **Configure Insights** .
2020-02-10 21:12:57 -05:00
2025-05-19 10:00:19 -07:00
1. Select **Enable** next to your virtual machine, and then **Enable on the Azure Monitor - Insights Onboarding** blade.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Take the defaults for subscription and data collection rules, then select **Configure** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. It will take a few minutes for the virtual machine agent to install and configure, proceed to the next step.
## Task 2: Create an alert
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
In this task, you create an alert for when a virtual machine is deleted.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Continue on the **Monitor** page , select **Alerts** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Create +** and select **Alert rule** .
2020-02-10 21:12:57 -05:00
2025-04-02 14:01:00 -07:00
1. Select the box for the subscription, then select **Apply** . This alert will apply to any virtual machines in the subscription. Alternatively, you could just specify one particular machine.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select the **Condition** tab and then select the **See all signals** link.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Search for and select **Delete Virtual Machine (Virtual Machines)** . Notice the other built-in signals. Select **Apply**
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. In the **Alert logic** area (scroll down), review the **Event level** selections. Leave the default of **All selected** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Review the **Status** selections. Leave the default of **All selected** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Leave the **Create an alert rule** pane open for the next task.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Task 3: Configure action group notifications
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
In this task, if the alert is triggered send an email notification to the operations team.
2020-02-10 21:12:57 -05:00
2025-05-19 10:00:19 -07:00
1. Continue working on your alert. Select **Use action groups** then select **Create action group** in the **Select action group** blade.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
>**Did you know?** You can add up to five action groups to an alert rule. Action groups are executed concurrently, in no specific order. Multiple alert rules can use the same action group.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. On the **Basics** tab, enter the following values for each setting.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
| Setting | Value |
|---------|---------|
| **Project details** |
| Subscription | your subscription |
| Resource group | **az104-rg11** |
| Region | **Global** (default) |
| **Instance details** |
| Action group name | `Alert the operations team` (must be unique in the resource group) |
| Display name | `AlertOpsTeam` |
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Next: Notifications** and enter the following values for each setting.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
| Setting | Value |
|---------|---------|
| Notification type | Select **Email/SMS message/Push/Voice** |
| Name | `VM was deleted` |
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Email** , and in the **Email** box, enter your email address, and then select **OK** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
>**Note:** You should receive an email notification saying you were added to an action group. There may be a few minutes delay, but that is a sure sign the rule has deployed.
2020-02-10 21:12:57 -05:00
2025-04-02 14:01:00 -07:00
1. Select **Review + Create** and then **Create** .
2024-02-23 07:32:32 -08:00
1. Once the action group is created move to the **Next: Details** tab and enter the following values for each setting.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
| Setting | Value |
|---------|---------|
| Alert rule name | `VM was deleted` |
| Alert rule description | `A VM in your resource group was deleted` |
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Review + create** to validate your input, then select **Create** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Task 4: Trigger an alert and confirm it is working
2020-10-24 13:28:54 -04:00
2024-02-23 07:32:32 -08:00
In this task, you trigger the alert and confirm a notification is sent.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
>**Note:** If you delete the virtual machine before the alert rule deploys, the alert rule might not be triggered.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. In the portal, search for and select **Virtual machines** .
2021-02-03 15:20:29 +01:00
2024-02-23 07:32:32 -08:00
1. Check the box for the **az104-vm0** virtual machine.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Delete** from the menu bar.
2020-02-10 21:12:57 -05:00
2024-11-04 13:43:07 +02:00
1. Check the box for **Apply force delete** . Check the box at the bottom confirming that you want the resources to be deleted and select **Delete** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. In the title bar, select the **Notifications** icon and wait until **vm0** is successfully deleted.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. You should receive a notification email that reads, **Important notice: Azure Monitor alert VM was deleted was activated...** If not, open your email program and look for an email from azure-noreply@microsoft .com.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00

1. On the Azure portal resource menu, select **Monitor** , and then select **Alerts** in the menu on the left.
2020-05-10 18:46:00 -04:00
2024-02-23 07:32:32 -08:00
1. You should have three verbose alerts that were generated by deleting **vm0** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
>**Note:** It can take a few minutes for the alert email to be sent and for the alerts to be updated in the portal. If you don't want to wait, continue to the next task and then return.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select the name of one of the alerts (For example, **VM was deleted** ). An **Alert details** pane appears that shows more details about the event.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Task 5: Configure an alert processing rule
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
In this task, you create an alert rule to suppress notifications during a maintenance period.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Continue in the **Alerts** blade, select **Alert processing rules** and then ** + Create**.
2025-04-02 14:01:00 -07:00
1. Select your **Subscription** , then select **Apply** .
2024-02-23 07:32:32 -08:00
1. Select **Next: Rule settings** , then select **Suppress notifications** .
1. Select **Next: Scheduling** .
1. By default, the rule works all the time, unless you disable it or configure a schedule. You are going to define a rule to suppress notifications during overnight maintenance.
Enter these settings for the scheduling of the alert processing rule:
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
| Setting | Value |
|---------|---------|
| Apply the rule | At a specific time |
| Start | Enter today's date at 10 pm. |
| End | Enter tomorrow's date at 7 am. |
| Time zone | Select the local timezone. |
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00

2020-10-24 13:28:54 -04:00
2024-02-23 07:32:32 -08:00
1. Select **Next: Details** and enter these settings:
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
| Setting | Value |
|---------|---------|
| Resource group | **az104-rg11** |
| Rule name | `Planned Maintenance` |
| Description | `Suppress notifications during planned maintenance.` |
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Select **Review + create** to validate your input, then select **Create** .
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
## Task 6: Use Azure Monitor log queries
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
In this task, you will use Azure Monitor to query the data captured from the virtual machine.
2020-02-10 21:12:57 -05:00
2025-04-02 14:01:00 -07:00
1. In the Azure portal, search for and select `Monitor` , then click **Logs** .
1. If necessary, close the splash screen.
2020-02-10 21:12:57 -05:00
2025-04-02 14:01:00 -07:00
1. If necessary, select a scope, your **Subscription** . Select **Apply** .
2020-02-10 21:12:57 -05:00
2025-04-02 14:01:00 -07:00
1. In the **Queries** tab, select **Virtual machines** (left pane). You may need to reopen the blade.
2020-02-10 21:12:57 -05:00
2025-04-02 14:01:00 -07:00

2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Review the queries that are available. **Run** (hover over the query) the **Count heartbeats** query.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. You should receive a heartbeat count for when the virtual machine was running.
2020-02-23 16:19:39 -05:00
2025-05-19 10:03:20 -07:00
1. On the right side of the screen select the drop down next to **Simple mode** , choose **KQL mode** . Review the query. This query uses the *heartbeat* table.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
1. Replace the query with this one, and then click **Run** . Review the resulting chart.
2020-02-10 21:12:57 -05:00
```
2024-02-23 07:32:32 -08:00
InsightsMetrics
| where TimeGenerated > ago(1h)
| where Name == "UtilizationPercentage"
| summarize avg(Val) by bin(TimeGenerated, 5m), Computer //split up by computer
| render timechart
2020-07-03 14:53:54 -04:00
```
2020-02-10 21:12:57 -05:00
2025-05-19 10:03:20 -07:00
>**Note:** If the query does not paste correctly, try pasting into Notepad and then copying and re-pasting into the query field.
2024-02-23 07:32:32 -08:00
1. As you have time, review and run other queries.
2022-05-08 19:26:41 +12:00
2024-02-23 07:32:32 -08:00
>**Did you know?**: If you want to practice with other queries, there is a [Log Analytics Demo Environment ](https://learn.microsoft.com/azure/azure-monitor/logs/log-analytics-tutorial#open-log-analytics ).
>**Did you know?**: Once you find a query you like, you can create an alert from it.
2022-05-08 19:26:41 +12:00
2024-02-23 07:32:32 -08:00
## Cleanup your resources
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
If you are working with **your own subscription** take a minute to delete the lab resources. This will ensure resources are freed up and cost is minimized. The easiest way to delete the lab resources is to delete the lab resource group.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
+ In the Azure portal, select the resource group, select **Delete the resource group** , **Enter resource group name** , and then click **Delete** .
+ Using Azure PowerShell, `Remove-AzResourceGroup -Name resourceGroupName` .
+ Using the CLI, `az group delete --name resourceGroupName` .
2020-02-10 21:12:57 -05:00
2024-05-10 07:41:11 -07:00
## Extend your learning with Copilot
Copilot can assist you in learning how to use the Azure scripting tools. Copilot can also assist in areas not covered in the lab or where you need more information. Open an Edge browser and choose Copilot (top right) or navigate to *copilot.microsoft.com* . Take a few minutes to try these prompts.
+ What are the basic configuration steps to be alerted in Azure when a virtual machine is down?
+ How can I be notified when an Azure alert is triggered?
+ Construct an Azure Monitor query to provide virtual machine CPU performance information.
## Learn more with self-paced training
+ [Improve incident response with alerting on Azure ](https://learn.microsoft.com/en-us/training/modules/incident-response-with-alerting-on-azure/ ). Respond to incidents and activities in your infrastructure through alerting capabilities in Azure Monitor.
+ [Monitor your Azure virtual machines with Azure Monitor ](https://learn.microsoft.com/en-us/training/modules/monitor-azure-vm-using-diagnostic-data/ ). Monitor your Azure VMs by using Azure Monitor to collect and analyze VM host and client metrics and logs.
2024-02-23 07:32:32 -08:00
## Key takeaways
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
Congratulations on completing the lab. Here are the main takeaways for this lab.
2020-02-10 21:12:57 -05:00
2024-02-23 07:32:32 -08:00
+ Alerts help you detect and address issues before users notice there might be a problem with your infrastructure or application.
+ You can alert on any metric or log data source in the Azure Monitor data platform.
+ An alert rule monitors your data and captures a signal that indicates something is happening on the specified resource.
+ An alert is triggered if the conditions of the alert rule are met. Several actions (email, SMS, push, voice) can be triggered.
+ Action groups include individuals that should be notified of an alert.