Introduction
Monitoring an Azure Linux virtual machine empowers teams to receive timely alerts on critical infrastructure changes and quickly address issues that could impact business operations.
Through Azure Monitor, Log Analytics, and other tools, you can set up an efficient monitoring system that includes alerts, diagnostics, and automation.
This article guides you through setting up Azure Monitor and Log Analytics for your virtual machine. It enables you to configure alerts, create action groups, and even simulate real-world scenarios. Whether you're just exploring or actively managing VMs, these skills are essential for keeping your cloud infrastructure running smoothly.
Architecture diagram
Table of contents
- Create a virtual machine (import a template).
- Configure VM Insights.
- Configure action groups and notifications.
- Create alerts.
- Trigger an alert by resizing the virtual machine.
- Configure an alert processing rule (optional).
Create a virtual machine (import a template)
Use a template to deploy a virtual machine.
- Download the
\Allfiles\Lab02\
lab files:
https://github.com/MicrosoftLearning/AZ-104-MicrosoftAzureAdministrator/blob/master/Allfiles/Labs/11/az104-11-vm-template.json
- Sign in to the Azure portal,
https://portal.azure.com
. - Cancel the Welcome to Microsoft Azure splash screen.
- Search for and select
Deploy a custom template
. - On the custom deployment page, select
Build your own template in the editor
. - On the edit template page, select
Load file
. - Locate and select the \Allfiles\Lab02\azuredeploy.json file and select
Open
. Take a moment to review the template. We are deploying a virtual network with a Linux virtual machine -
Save
your changes. - Use the following information to complete the custom deployment fields, leaving all other fields with their default values:
- Select
Review + Create
, then selectCreate
. ###Configure VM Insights. To enable Insights for a virtual machine. - Continue in the Azure portal.
- Search for and select your virtual machine. Before proceeding, ensure the VM status is
Running
. - In the
Monitoring
section, selectInsights
, and thenEnable
. - For Data collection rule, select Create New.
- Set the Data collection rule name to
VM2Rule1
. - Take the default workspace for Log Analytics workspace drop down.
- Review the defaults and then select
Create
. - Ensure your new rule is selected in the Data collection rule drop-down, then select
Configure
.
Configure action groups
Steps to create an action group and configure a notification method.
- Continue working on your virtual machine. In the
Monitoring
section, selectAlerts
. - Select
+ Create
and thenAction group
. - On the
Basics
tab, enter the following values for each setting. - Select
Next: Notifications >
. Notifications determine how the action group is alerted. We will be using email notifications. - Select Email, and in the Email box, enter your email address, and then select
OK
. - Complete the Notifications tab by adding a Name for the action group,
Help Desk
. - Finish creating the action group by selecting
Review + Create
and thenCreate
.
Create alerts
Steps to create two alert rules.
- In the Monitor section, select Alerts.
- Select Create + and select Alert rule. Create an alert rule based on CPU percentage usage
- In the Signal name drop-down select Percentage CPU.
- You want to be alerted when the CPU threshold is over 90%. So, change the Threshold value to
90
. - You also need to adjust the When to evaluate settings. It is important to be reasonable about how often the alert is checked.
- Select the
Next: Actions>
tab,Use action groups
, then choose theHelp Desk
action group and click select . - Move to the Details tab, and complete the required information.
- Select Review + create, then select Create. Create an alert based on log activity
- Select Create + and select Alert rule.
- On the Condition tab select See all signals.
- Search for and select Create or Update Virtual Machine (Virtual Machines).
Apply
your changes. - In the Alert logic area (scroll down) review the Event level selections. Leave the default of All selected.
- Review the Status drop-down selections. Leave the default of All selected.
- On the Actions tab,
Use action groups
, then choose theHelp Desk
action group and clickSelect
. - Move to the Actions tab, Select action groups, then choose the
Help Desk
action group and clickSelect
. - Move to the Details tab and enter the following values for each setting.
- Select Review + create, then select Create.
Trigger an alert by resizing the virtual machine
Steps to review performance data and resize a virtual machine.
- Continue working with your virtual machine.
- In the Monitoring section select the Metrics blade. Take a few minutes to explore features like the variety of Line charts, chart Metrics, New alert rule from your data. You can Save to the dashboard.
- In the Monitoring section select the Logs blade. If necessary, close the Welcome to Log Analytics page. Take a few minutes to explore the Topic drop-down select Resource type and then Virtual machines, the Count heartbeats or Virtual Machine available memory. Take time to explore and Run any queries of interest.
- In the Availability + scale blade, select Size.
- Set the virtual machine size to DS2_v2 and click Resize. If prompted, confirm the change.
- Navigate to the Alerts blade. Resizing the virtual machine should have triggered your VM2Changed alert rule. If needed, Refresh the page.
- Select an alert and review the details. Edit the User response and ensure the status is Acknowledged. Save your changes.
- You should also receive an email notification that reads, Important notice: Azure Monitor alert VM was updated… If not, open your email program and look for an email from Azure-Noreply@microsoft.com.
Configure an alert processing rule (optional)
To create an alert processing rule.
- Continue in the Alerts blade, select Alert processing rules and then + Create.
- Notice the alert scope is VM2.
- Select Next: Rule settings, then select Suppress notifications.
- Select Next: Scheduling.
- Define a rule to suppress notifications during overnight maintenance.
- Select Next: Details and enter these settings:
- Select Review + create to validate your input, then select Create.
Top comments (2)
This article is quite helpful. Thanks for this write up
Very insightful and inspiring