Sharon demonstrates how to filter and create metrics for your virtual machines. Sharon also shows you how to create alerts when a specific threshold has been triggered on your virtual machine.
- [Instructor] In Azure, we still have to monitor our virtual machines just as we do on premise. Have you started to detect a theme yet? It doesn't matter where your infrastructure is. It can be in your data center, or in Azure, you still need to manage, maintain, and monitor it. Luckily, over the last 18 months, Microsoft has made it much easier to monitor your virtual machines. The Monitoring Agent virtual machine extension is included when you provision your virtual machines and diagnostics are enabled by default.
A virtual machine extension is a small application that runs post-deployment tasks. I'm going to show you how we set up monitoring and alerts for our virtual machines. As you can see, I have logged in to my Azure account, and I am viewing virtual machine, Prod1. From this view, you will see some basic monitoring results. I have CPU percentage, read disk write, network in out, but I can only see for the last hour. This is the default setting. If you would like to edit this, click Edit, and now you can change the Time Range to today, past week, or custom.
You can also change the Chart type from Bar to Line and back again. I like Lines, I'm going to keep it there. If you want to change the metric that is being monitored, you would uncheck what is currently being monitored, in our case the Percentage CPU, and then select what you would like to be monitored. Only specific metrics can be grouped together based on the monitoring calculation. For example, you could pair up Disk Read and Disk Write, because both metrics are calculated in operations per second.
Then you go ahead and click OK. You'll notice that we have more information being presented to us. Now this is a new virtual machine, therefore we can't go back a week, but you understand how you set this up now. These metrics are okay for a quick overview, but what if you're looking to filter based on subscription, resource group, or resource types? This can be achieved by selecting metrics under the Monitoring tab. You'll probably have to scroll down a little bit, and then click on Metrics. This tab is somewhat misleading.
You would think you would only be able to use metrics related to the virtual machine that you're currently in, but you can actually filter on your Subscriptions and Resource groups, Resource types, and the actual resources themselves. For example, right now I'm only filtering on Pay-As-You-Go Subscription. If I add my MSDN Subscription into this, I will now have all the resource groups for both of those subscriptions. I'm going to select my VMSSTest.
I can now go ahead and select my Storage Account or my Virtual Machine Scale Sets, or both, and then here I'm just going to pull up the Virtual Machine Scale Set. I can now filter on that virtual machine. For our demonstration today, I'm going to keep is consistent. I'm going to go back and configure this for our Prod1 virtual machine. I don't have to change the Subscription, because I know I'm going to look for the Production resource group. Our resource type will be a virtual machine, and I'm going to select Prod1.
Under Metrics, I am going to create a line graph for the Read, Write, and Network In, Out. We have all the information available for the last hour. You could pin this to the dashboard and then you would be able to see it whenever you logged in to Azure and looked at the dashboard view. I mean this is okay, but what good are the metrics if you're not being alerted to an issue? To set up the alerts, click the Add metric alert button at the top of the page. It's up here. We're going to provide a name for our metric.
In this case it's going to be when our CPU exceeds 80. Next we're going to select from our Criteria. Again, you could do it from any of your subscriptions. I want to keep it consistent to the Prod1 virtual machine, so our Resource group will be Production, our Resource is Prod1, and we actually want to filter on Percentage CPU. Our Condition, if it's Greater than, Greater than or equal to, Less than, or Less than and equal to. I'm going to go with Greater than. My Threshold will be 80, and this will be 80%.
We can see the percent way over to the right. Now I want to be notified when that CPU is over 80% over five minutes. You do have several options here to choose from. Now when this occurs, we want to notify the email owners, contributors, and readers, because what good is an alert if nobody knows about it? You can add in an additional administrator email if you wish. Next we have Webhooks. You can send the alert to another monitoring or tracking system by entering the URL. Finally, we can trigger another action when the alert is activated.
We can either use the Microsoft provided runbooks, or we can use our own. We will be discussing automation and automation accounts in another video, but for our example here, we're going to enable the runbook. We are going to use the Microsoft runbook, and we're going to go ahead and Scale Up our VM when it hits 80%. We'll choose our Automation account. I already have one created for us for this demo, and click OK. You'll notice that our action is now Scale Up the VM. Click OK again. Our alert will be created.
If I click on Alert rules, our rule is now available to us. That's it. Now when your CPU Threshold is greater than 80%, the appropriate people are notified, and the virtual machine will scale up automatically.
- Creating a Windows virtual machine
- Deploying a Linux virtual machine
- Using PowerShell for creating a Windows VM
- Configuring extensions
- Enabling remote debugging
- Configuring shared storage
- Configuring disk storage
- Working with Azure Disk Encryption
- Monitoring and creating VM alerts
- Configuring diagnostic and storage monitoring
- Creating availability sets
- Combining the load balancer with availability sets
- Scaling up and scaling down VM sizes
- Creating and modifying VM scale sets