Introduction
In this exercise, I learned how to use Azure Monitor to configure monitoring, alerts, and notifications for a Linux virtual machine (VM) on Azure. The goal was to explore the different monitoring features in Azure, including VM Insights, action groups, and alert processing rules, to ensure that the infrastructure changes or performance issues are detected and acted upon efficiently.
Scenario
My task was to monitor a newly created Azure Linux VM and set up alerts to notify me of any performance issues or changes, such as CPU usage spikes or VM modifications. I explored the process of enabling VM Insights for performance tracking, creating alerts based on CPU usage, and configuring action groups to notify administrators of critical events.
Skills Practiced:
- Enabling VM Insights for a virtual machine.
- Creating and managing action groups for alert notifications.
- Configuring alert rules based on metrics and log data.
- Triggering alerts through actions like resizing a virtual machine.
- Implementing alert processing rules for scheduled suppression during maintenance.
Step-by-Step Guide
Step 1: Create a Virtual Machine (Import a Template)
1️⃣ Sign in to the Azure Portal
I started by signing into the Azure portal.
2️⃣ Deploy a Virtual Machine Using a Template
- I navigated to the Deploy a custom template section.
- I uploaded the
azuredeploy.json
file for a Linux VM, specifying the following settings:
| Setting | Value |
|----------------------|--------------------|
| Subscription | Your Azure subscription |
| Resource group | RG1 |
| Region | East US |
| VM Name | VM2 |
| Username | adminuser |
| Password | Provided a complex password |
I selected Review + Create, then clicked Create to deploy the VM.
Step 2: Configure VM Insights
1️⃣ Enable VM Insights
I selected my newly created VM and went to Monitoring > Insights. Then, I clicked Enable.
2️⃣ Create a Data Collection Rule
- I named the Data Collection Rule VM2Rule1 and selected the default Log Analytics workspace.
- I reviewed and clicked Create to enable VM Insights for the virtual machine.
Step 3: Configure Action Groups
1️⃣ Create an Action Group
- I navigated to Monitoring > Alerts and selected + Create to create an action group. I named it Help Desk.
| Setting | Value |
|-------------------------|-----------------------------|
| Project details | Your subscription, RG1 |
| Action Group Name | Help Desk |
| Display Name | Help Desk |
2️⃣ Configure Email Notifications
- I added an Email notification type and entered my email address to receive alerts.
3️⃣ Finalize the Action Group
I clicked Review + Create and then Create to finish setting up the action group.
Step 4: Create Alerts
1️⃣ Create an Alert Based on CPU Percentage Usage
I created an alert rule to notify me when the CPU percentage exceeds 90%.
| Setting | Value |
|------------------------|-----------------------------|
| Signal Name | Percentage CPU |
| Threshold Value | 90 |
| Loopback Period | 1 hour |
| Check Every | 1 hour |
| Severity | 2 - Warning |
I selected the Help Desk action group to be notified via email.
2️⃣ Create an Alert Based on Log Activity
I created another alert based on Create or update virtual machine (Virtual Machines) logs.
| Setting | Value |
|----------------------------|-----------------------------------|
| Alert Rule Name | VM2Changed |
| Alert Rule Description | VM2 was updated or deleted |
I assigned the Help Desk action group for notifications.
Step 5: Trigger an Alert by Resizing the Virtual Machine
1️⃣ Resize the Virtual Machine
I reviewed the performance data for the VM and noticed that the CPU usage was close to its limit. To trigger the alert, I resized the VM to a Standard DS11-1 v2.
I went to Availability + scale > Size and changed the VM size. This triggered the VM2Changed alert.
2️⃣ Review the Triggered Alert
After resizing the VM, I navigated to the Alerts section, where I saw that the alert was triggered. I acknowledged the alert and confirmed that I received the email notification for the update.
Step 6: Configure an Alert Processing Rule (Optional)
1️⃣ Create an Alert Processing Rule
To prevent unnecessary notifications during scheduled maintenance, I configured an alert processing rule to suppress notifications from 10 PM to 7 AM.
I created a rule named Planned Maintenance with the following settings:
| Setting | Value |
|------------------------|----------------------|
| Start Time | Today at 10 PM |
| End Time | Tomorrow at 7 AM |
| Time Zone | Local time zone |
This rule was designed to suppress notifications during the maintenance period.
Challenges Encountered and Resolved
Alert Triggering Issue:
Initially, the alert wasn’t triggered when I resized the VM. After reviewing the configuration, I realized the action group was not properly associated with the alert. I fixed this by associating the correct action group to each alert rule, ensuring I was notified upon alert activation.Email Notification Delay:
There was a slight delay in receiving the email notifications after resizing the VM. This was expected as Azure's alert processing can take a few minutes to send out notifications, especially when dealing with high-frequency alerts.
Key Learnings
1️⃣ Azure Monitor & VM Insights
Azure Monitor is a powerful tool for monitoring resources. VM Insights collects important performance data, such as CPU usage, memory usage, and disk I/O, for a more comprehensive monitoring experience.
2️⃣ Alert Configuration
I learned how to configure alerts based on metrics like CPU percentage and events such as VM updates. Alerts can help administrators stay informed about critical changes or performance issues in real time.
3️⃣ Action Groups for Notifications
Action groups allow for flexible notification configurations. I configured email notifications to be sent whenever an alert was triggered, ensuring I am always notified of important changes.
4️⃣ Alert Processing Rules
I explored alert processing rules, which allow for greater control over when and how alerts are processed. These can be useful for suppressing alerts during scheduled maintenance or low-priority periods.
Conclusion
This exercise helped me get hands-on experience with Azure Monitor and VM Insights to effectively manage and monitor Azure Linux virtual machines. I learned how to set up alerts based on various performance metrics and log events, and I explored how to use action groups for alert notifications. Additionally, I configured alert processing rules to prevent unnecessary notifications during maintenance periods.
By mastering these tasks, I can now efficiently monitor the health and performance of my virtual machines in Azure and respond to any issues in a timely manner.
🚀 Stay tuned for more as I continue my Azure learning journey!
Top comments (0)