Adatum Corporation wants to explore monitoring capabilities in Azure
After completing this lab, you will be able to:
-
Deploy Azure VM scale sets
-
Implement monitoring and alerting by using Azure Monitor
Estimated Time: 45 minutes
User Name: Student
Password: Pa55w.rd1234
The main tasks for this exercise are as follows:
-
Deploy an Azure VM scale set by using an Azure QuickStart template
-
Review autoscaling settings of the Azure VM scale set
-
From the lab virtual machine, start Microsoft Edge and browse to the Azure portal at http://portal.azure.com and sign in by using the Microsoft account that has the Owner role in the target Azure subscription.
-
In the Azure portal, in the Microsoft Edge window, start a PowerShell session within the Cloud Shell.
-
If you are presented with the You have no storage mounted message, click Show Advanced Settings and then configure storage using the following settings:
-
Subscription: the name of the target Azure subscription
-
Cloud Shell region: the name of the Azure region that is available in your subscription and which is closest to the lab location
-
Resource group: the name of a new resource group az3000100-LabRG
-
Storage account: a name of a new storage account (between 3 and 24 characters consisting of lower case letters and digits)
-
File share: a name of a new file share: cloudshell
-
-
From the Cloud Shell pane, run the following command to identify a unique DNS domain name (substitute the placeholder
<custom-label>
with any alphanumeric string starting with a letter and no longer than 9 characters, which is likely to be unique and the placeholder<location>
with the name of the Azure region into which you intend to deploy resources in this lab):Test-AzDnsAvailability -DomainNameLabel <custom-label> -Location '<location>'
- For example: Test-AzDnsAvailability -DomainNameLabel az300la01 -Location 'East US'
-
Verify that the command returned True. If not, rerun the same command with a different value of the
<custom-label>
until the command returns True. -
Note the value of the
<custom-label>
that resulted in the successful outcome. You will need it in the next task. -
From the lab virtual machine, start Microsoft Edge and browse to the Azure QuickStart template that deploys autoscale demo app on Ubuntu 16.04.
-
Click Deploy to Azure and, when prompted, sign in by using the Microsoft account that has the Owner role in the target Azure subscription.
-
In the Azure Portal, on the Deploy VM Scale Set with Python Bottle server & AutoScale blade, specify the following settings and initiate the deployment:
-
Subscription: the name of the target Azure subscription
-
Resource group: the name of a new resource group az3000101-LabRG
-
Location: the name of the Azure region that you referenced when running
Test-AzDnsAvailability
earlier in this task -
Vm Sku: Standard_D2_v3
-
Vmss Name: the custom label you identified when running
Test-AzDnsAvailability
earlier in this task -
Instance count: 1
-
Admin Username: student
-
Authentication Type: password
-
Admin Password: Pa55w.rd1234
-
-
Place a checkmark next to I agree to the terms and conditions stated above, and then click Purchase.
-
Wait for the deployment to complete. This will take about 5 minutes.
-
In Azure Portal, navigate to the blade representing the newly deployed Azure VM scale set.
-
From the VM scale set blade, navigate to the its Scaling blade.
-
Note that the Azure VM scale set is configured to scale dynamically based on a metric using the following criteria:
-
Scale out: increase instance count by 1 when average percentage of CPU > 60
-
Scale in: decrease instance count by 1 when average percentage of CPU < 30
-
Minimum number of instances: 1
-
Maximum number of instances: 10
-
-
Modify the maximum number of instances to 3 and save your changes.
Result: After you completed this exercise, you have deployed an Azure VM scale set and reviewed its autoscaling settings.
The main tasks for this exercise are as follows:
-
Create Azure VM scale set metrics-based alerts
-
Configure Azure VM scale set autoscaling-based notifications
-
Test Azure VM scale set monitoring and alerting.
-
In the Azure portal, navigate to the blade representing the newly deployed Azure VM scale set and, from there, switch to the Monitoring - Metrics blade.
-
On the Monitoring - Metrics blade, use the filter to display Percentage CPU metric with an aggregation value of Avg of the VM scale set resource you provisioned in the previous exercise of this lab.
-
Review the resulting chart and note the average percentage CPU within the last few minutes.
-
Navigate to the Alerts blade in the Monitoring section.
-
From the Alerts blade, navigate to the Manage actions blade.
-
In the Manage actions section, click Add action group, set the action group name to az30001 action group, set short name: az30001, select the Azure subscription you used in the previous exercise, accept the default name of the resource group of Default-ActivityLogAlerts (to be created), set the action group name: az30001-email, and set the action type to Email/SMS/Push/Voice.
-
On the Email/SMS/Push/Voice blade, set an email address, a mobile phone number, or a phone number that you want to use to receive alerts generated by this rule.
-
On the Add action group page, click OK.
-
Navigate to the Alerts blade.
-
From the Alerts blade, navigate to the New alert rule blade.
-
In the Resource section, select the VM scale set you provisioned in the previous exercise of this lab.
-
In the Condition section, click Add condition, select the Percentage CPU metric, leave the dimension settings and condition type with their default values, set the condition to Greater than, set the type aggregation to Average, set the threshold to 60, set the Aggregation granularity (period) to 1 minute, set the frequency to Every 1 minute and click done.
-
In the Actions section, click Select action group, select previously created action group az30001 action group and click done.
-
In the Alert Details section, set the alert rule name to Percentage CPU of the VM scale set is greater than 60 percent, its description to Percentage CPU of the VM scale set is greater than 60 percent, its severity to Sev 3, and set enable rule upon creation to Yes.
-
Click Create alert rule.
Note: It can take up to 10 minutes for a metric alert rule to become active.
-
In the Azure portal, navigate to the blade representing the newly deployed Azure VM scale set and, from there, switch to the Scaling blade.
-
On the Scaling blade, click the Notify tab heading, configure the following settings, and save your changes:
-
Email administrators: enabled
-
Email co-administrators: disabled
-
Additional administrator emails(s): add an email address that you want to use to receive notifications about autoscaling events
-
-
In the Azure portal, search for Load balancers and navigate to the Load Balancers blade. A load balancer should exist, representing the one created with the scale set you deployed from a template in a previous exercise of this lab.
-
Identify the value of the Public IP address assigned to the front end of the load balancer associated with the VM scale set.
-
From the lab computer, SSH to your first VM instance. Specify your own public IP address and port number with the -p parameter, as shown from the preceding command:
ssh student@13.92.224.66 -p 50000
-
Once logged in, install the stress utility. Start 10 stress workers that generate CPU load. These workers run for 420 seconds, which is enough to cause the autoscale rules to implement the desired action.
sudo apt-get -y install stress sudo stress --cpu 10 --timeout 420 &
-
To confirm that stress generates CPU load, examine the active system load with the top utility:
top
-
Use the CPU (average) chart on the VM scale set Overview blade to monitor changes to the CPU utilization.
Note: Alternatively, you can navigate back to the Metrics blade and use the filter to display Percentage CPU metric of the VM scale set resource, and set the time to Last 30 minutes.
Note: You should receive an alert regarding increased CPU utilization within a couple of minutes
-
Switch to the Instances blade of the VM scale set in order to identify the number of its instances.
Note: Alternatively, you can navigate back to the Scaling blade, in the list of resources capable of autoscaling, click the name of the VM scale set, on the Autoscale settings blade, click Run history, and then review the list of autoscale events.
Note: Autoscaling should be triggered within a couple of minutes.
-
Switch to the Microsoft Edge window displaying worker instances page and click the Stop work link.
-
Monitor decrease in CPU utilization and scaling in events using the same methods that you used when scaling out the VM scale set.
Result: After you completed this exercise, you have implemented and tested monitoring and alerting by using Azure Monitor.
The main tasks for this exercise are as follows:
-
Discover resource groups created in this lab
-
Delete resource groups created in this lab
-
At the top of the portal, click the Cloud Shell icon to open the Cloud Shell panel and switch to the PowerShell shell if necessary.
-
At the Cloud Shell command prompt, type in the following command and press Enter to list all resource groups you created in this lab:
Get-AzResourceGroup -Name 'az300010*'
-
Verify that the output contains only the resource groups you created in this lab. These groups will be deleted in the next task.
-
At the Cloud Shell command prompt, type in the following command and press Enter to delete the resource groups you created in this lab
Get-AzResourceGroup -Name 'az300010*' | Remove-AzResourceGroup -Force -AsJob
Note: The command executes asynchronously (as determined by the -AsJob parameter), so while you will be able to run another PowerShell command immediately afterwards within the same PowerShell session, it will take a few minutes before the resource groups are actually removed.
-
Close the Cloud Shell prompt at the bottom of the portal.
Result: After you completed this exercise, you removed the resources used in this lab.