How To Configure Azure Monitoring Using Custom Template

Introduction

 
Any service created in Azure can be monitored by the Azure monitoring system which help to maximize the performance of your applications by collecting, analyzing, and acting on telemetry from your cloud and on-premises environments. It helps you to understand your application performance, like how many users are  accessing your service, total resources consumed by VM, percentage cpu, RAM , ROM etc. 
 

Configure Matrices/Scaling/Alert using Azure Portal

 
Let's understand step by step how to configure and use the monitoring system with matrices, scaling and alerts etc. I will be using a predefined Azure custom template to create the app and monitor that app performance by creating matrices, scaling and alerts. I will be using "201-vmss-bottle-autoscale" template to see VM scaling/load balancing/cpu usage percentage and add alert on cpu percentage and get the action on your mail.
 
Step 1
 
Open Azure portal -> go to Create resource -> Template deployment (deploy using custom templates)
 
How To Configure Azure Monitoring Using Custom Template
 
Step 2
 
Create 201-vmss-bottle-autoscale template which is build on python to just check the CPU percentage etc.
 
How To Configure Azure Monitoring Using Custom Template
 
How To Configure Azure Monitoring Using Custom Template
 
Add total instance as 2 so that we can check load balancing and give the unique name for vmss etc and purchase it. A new instance of this custom template will be created. you may notice that 4 resources are created: "Vm scale set", "load balancer", "public IP", and "virtual network"
 
Step 3
 
Go to VM Scale, set resource, and copy the IPaddress and open in new tab by adding port which you can find under loadbalancer->Inbound NAT rules. In my case it'shttp://52.172.8.115:9000/ which opens a webpage to start work.
 
How To Configure Azure Monitoring Using Custom Template
 
How To Configure Azure Monitoring Using Custom Template
 
Step 4
 
Let's create a matrix of percentage cpu by going to matrices under vm scale, and set resource. Create a new rule and select matrix as cpu percentage.
 
How To Configure Azure Monitoring Using Custom Template
 
Here, you can verify percentage cpu average when work was started from web. You can see how cpu goes high when you start the work from web.
 
Step 5
 
Let's define the alert when cpu percentage goes high to threshold value. Go to alert under monitor and create new alert rule.
  • Select the resource under the resource group which you want to add alert.
  • Add condition by selecting signal as cpu percentage and add the threshold value by adding condition, in my case I have added condition when threshold value is greater than 47 and evaluated  every 1 minute.
  • Next step is to add action like get sms, mail etc. when condition is met, give your mail and mobile number so that alert is sent when given condition is met.
Finally add alert rule name, description and set the severity. ser0 is lower and ser4 is highest. And click on create alert rule.
 
How To Configure Azure Monitoring Using Custom Template
 
You will have noticed how matrices and alerts are configured and managed by Azure. Similarly, you can go to scale option and see the default auto scale rules defined. Here you may notice that default scale condition is defined based in cpu percentage > 60 then add new instance of VM etc.
 

Conclusion

 
Here, we have experienced how to work with Azure monitoring system to configure scaling, matrices, and alerts in the Azure protal.


Similar Articles