The virtual machine on Azure can monitor the guest operating system’s data, such as CPU, memory usage, and so on, by enabling guest OS diagnostic data collection. And even better, we can also manage VMs based on monitored data, such as vertical scaling. This article will talk about how to use the memory usage to automatically extend the virtual machine vertically.
1. First enable guest OS diagnostics data collection so that we can collect more disk, CPU, and memory data. If it is not checked during creation, it can be configured by monitoring the diagnostic settings in the VM panel.
2. Click on the alert rule under monitoring to create an alert rule. You can choose your own metrics. Since we are expanding based on memory here, we choose the percentage of memory that has been used here.
3. Select a threshold, the condition is greater than. This means that when the memory usage exceeds the threshold, this alarm is triggered to execute the action. The period is a time range of data statistics.
4. Finally choose to take action, which Azure has built a lot of scripts for us to use. Since we need to scale up here, select Scale up VM. Then select one of our automated accounts or create a new one.
The above is how to automatically expand the virtual machine by monitoring the memory usage. For more information, refer to https://docs.azure.cn/zh-cn/virtual-machines/windows/monitor以及https://docs.azure.cn/zh-cn/virtual-machines/windows/tutorial-monitoring 。
This article demonstrates how to automate VM vertical scaling based on memory usage. But this is just one example. In fact you can do more with other diagnostic data and other Runhook sources. If you have any questions, please contact us at aka.ms/devchat.