DEV Community

Cover image for Unlock Your Azure Linux VM’s Potential with Proactive Monitoring
Oluwatobiloba Akinbobola
Oluwatobiloba Akinbobola

Posted on

Unlock Your Azure Linux VM’s Potential with Proactive Monitoring

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

VM lab2

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.

  1. Download the \Allfiles\Lab02\ lab files:
https://github.com/MicrosoftLearning/AZ-104-MicrosoftAzureAdministrator/blob/master/Allfiles/Labs/11/az104-11-vm-template.json
Enter fullscreen mode Exit fullscreen mode
  1. Sign in to the Azure portal, https://portal.azure.com.
  2. Cancel the Welcome to Microsoft Azure splash screen.
  3. Search for and select Deploy a custom template. Deploy a custom template
  4. On the custom deployment page, select Build your own template in the editor. Build your own template
  5. On the edit template page, select Load file.
  6. Locate and select the \Allfiles\Lab02\azuredeploy.json file and select Open. Open JSON Take a moment to review the template. We are deploying a virtual network with a Linux virtual machine
  7. Save your changes.
  8. Use the following information to complete the custom deployment fields, leaving all other fields with their default values: custom deployment
  9. Select Review + Create, then select Create. Create deployment ###Configure VM Insights. To enable Insights for a virtual machine.
  10. Continue in the Azure portal.
  11. Search for and select your virtual machine. Before proceeding, ensure the VM status is Running. running VM
  12. In the Monitoring section, select Insights, and then Enable. Monitoring Enabled
  13. For Data collection rule, select Create New.
  14. Set the Data collection rule name to VM2Rule1.
  15. Take the default workspace for Log Analytics workspace drop down.
  16. Review the defaults and then select Create. Data collection rule name
  17. Ensure your new rule is selected in the Data collection rule drop-down, then select Configure. Data collection rule

Configure action groups

Steps to create an action group and configure a notification method.

  1. Continue working on your virtual machine. In the Monitoring section, select Alerts.
  2. Select + Create and then Action group. Action group
  3. On the Basics tab, enter the following values for each setting. Basic
  4. Select Next: Notifications >. Notifications determine how the action group is alerted. We will be using email notifications.
  5. Select Email, and in the Email box, enter your email address, and then select OK. Email
  6. Complete the Notifications tab by adding a Name for the action group, Help Desk.
  7. Finish creating the action group by selecting Review + Create and then Create. Notification help desk

Create alerts

Steps to create two alert rules.

  1. In the Monitor section, select Alerts.
  2. Select Create + and select Alert rule. Alert rule Create an alert rule based on CPU percentage usage
  3. In the Signal name drop-down select Percentage CPU.
  4. You want to be alerted when the CPU threshold is over 90%. So, change the Threshold value to 90.
  5. You also need to adjust the When to evaluate settings. It is important to be reasonable about how often the alert is checked. CPU percentage usage
  6. Select the Next: Actions> tab, Use action groups, then choose the Help Desk action group and click select . Use action groups
  7. Move to the Details tab, and complete the required information. Alert rule details
  8. Select Review + create, then select Create. Alert rule create Alert rule create2 Create an alert based on log activity
  9. Select Create + and select Alert rule.
  10. On the Condition tab select See all signals. See all signals
  11. Search for and select Create or Update Virtual Machine (Virtual Machines). Apply your changes. Update VM
  12. In the Alert logic area (scroll down) review the Event level selections. Leave the default of All selected.
  13. Review the Status drop-down selections. Leave the default of All selected.
  14. On the Actions tab, Use action groups, then choose the Help Desk action group and click Select. Alert logic help desk
  15. Move to the Actions tab, Select action groups, then choose the Help Desk action group and click Select.
  16. Move to the Details tab and enter the following values for each setting. Alert rule description
  17. Select Review + create, then select Create. Alert create

Trigger an alert by resizing the virtual machine

Steps to review performance data and resize a virtual machine.

  1. Continue working with your virtual machine.
  2. 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. Metrics
  3. 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. Monitoring VM Take time to explore and Run any queries of interest. Run Queries
  4. In the Availability + scale blade, select Size.
  5. Set the virtual machine size to DS2_v2 and click Resize. If prompted, confirm the change. VM Availability resize
  6. Navigate to the Alerts blade. Resizing the virtual machine should have triggered your VM2Changed alert rule. If needed, Refresh the page. Alert refresh
  7. Select an alert and review the details. Edit the User response and ensure the status is Acknowledged. Save your changes. Acknowledged alert
  8. 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.

  1. Continue in the Alerts blade, select Alert processing rules and then + Create. Alert processing rules
  2. Notice the alert scope is VM2.
  3. Select Next: Rule settings, then select Suppress notifications. Suppress notifications
  4. Select Next: Scheduling. Suppress notifications
  5. Define a rule to suppress notifications during overnight maintenance. suppress notifications rule
  6. Select Next: Details and enter these settings: Next: Details
  7. Select Review + create to validate your input, then select Create. suppress notification created Resource group created

Top comments (2)

Collapse
 
etiifiok_udofiah_eb450b4b profile image
etiifiok udofiah

This article is quite helpful. Thanks for this write up

Collapse
 
esther_akinbobola_917f39a profile image
Esther Akinbobola

Very insightful and inspiring