As workloads increase or decrease, Azure Virtual Machine Scale Sets (VMSS), a feature of Microsoft Azure, let you install and manage a group of similar virtual machines, often known as instances. The number of instances is automatically scaled by VMSS depending on established criteria and conditions, ensuring that the application can effectively handle fluctuations in demand.
Setting up alerts in Azure VM Scale Sets:
You can set up monitoring and alerts to guarantee the best performance and availability of your application operating on a VM Scale Set. You can set up alerts based on particular measurements and circumstances using Azureās monitoring tool, Azure Monitor.
Prerequisites:-
- Our role in Azure should have write access to the VMs, so that we can enable Insights in Monitoring and get the Performance status.
First, we have to go to the scaleset where we want to enable monitoring insights. We can enable Insights from Monitoring >> Insights.
- After enabling Insights, we need to configure alert rules, for that Monitoring >> Alerts >> Create.
Create Action Group
While creating action group, we have to specify the Subscription, resource group and Region of the Action group. Once we fill this fields we can give a name to the action group.
Then we can move on to Notifications, from there we can choose 2 types of notifications Email / SMS Message / Push / Voice and Email Azure Management Role. We can go with Email notification type and then we can enter the email address to where we need to push the mail.
Then select what type of action that need to be initiate once the Action group trigger. There are different types of actions:
For pushing notifications to teams we can select the action type as Webhook, once we select it we can enter a name and add the URL which we are generated from the teams channel. Then we can add tags if we want.
Once Action group is created we can test it by using the option Test action group, if the action group configured correctly it will send test alert to email and teams as well.
Once the test alert succeeded we can create Alert rule using the newly created Action group.
Creating Alert rule
From Monitoring >> Alerts >> Create >> Alert rule.
Select for what kind of resource we are setting alert. Here we are selecting Percentage CPU, a space will appear to specify the condition when we need to trigger the alert. We need to specify our requirement in it.
After specifying this, go to the next field Actions, here we can either create a new action group or select an existing action group. Since we have already created action group we can go with that one.
After selecting the action group, in the field Details specify the Resource group, Alert rule name and its description.
Thatās all we have completed the setup. We can check the working by selecting the Action group which we have assigned to our Alert rule, there will be an edit option. Click on the edit option, it will open a new console where you can test it by clicking on the Test action group option in the top.
Before clicking on the Test option we need to specify a sample alert template in the Select sample type field.