Azure Monitor: How to setup alert and actions?

Table of contents
Reading Time: 3 minutes
Table of contents:
Offerings by Azure Monitor
Metrics vs Logs
Setting up Alert and action


Azure monitor is a full stack monitoring service inside the Azure, provides end to end monitoring for applications and underlying infrastructure. On the other hand, It captures metrics and logs for the monitored services like (Azure resources, On-premises resources, platform services and application code). It delivers a comprehensive solution for collecting, analyzing, and acting on telemetry from your cloud and on-premises environments. And then, we can use this information to proactively identify the issues that can affect the applications and the resources they are hosted on, and understand how to address them.

Features offered by Azure Monitor:

Azure monitor collects metrics and logs from the monitored resources, we can take these data-sources metrics and logs which can be stored or viewed from the places (Azure Monitor, Log Analytics, Storage Accounts and Event hub). Metrics can be sent to all the listed destinations however, logs can be sent to (Log Analytics, Storage account and Event hub). We can further use the tools like Metrics explorer, Log analytics with custom query language and Event hub to send it to other tools outside the Azure for deep analysis.

Metrics vs Logs:

Short, time-based data
Frequently updated
Near real time data
Alerts based on Numeric values
Visualization via metrics explorer
Metrics are gathered on a per resource basis
Long, event based data
Infrequently updated
Stored in log Analytics workspace
Free form or Structured
Logs are not gathered by default by Azure

Setting up Alert and Actions:

For this instance, we will setup an alert and action to determine and send out a notification when a Virtual machine has been stopped and also could be restarted whenever such conditions has met.

1. Firstly, Go to search pane on the Azure portal search monitor, click on alert inside monitor and create an alert rule. Further, specify a scope for what you want to setup alert. On this occasion, I am setting it for virtual machine.

2. Secondly, Specify condition to trigger the alert rule on a specific signal. Furthermore, Select the signal type as activity log and select the signal as Deallocate Virtual Machine.

3. In addition, setup an action, create an action group. In addition, setup notification detail to get an alert, here I have set it to SMS by supplying the contact number. Under Action, select Automation run book. Click Create.

4. Provide alert rule details such as name and Resource group. Lastly, Click on create. It will take a few minutes. And then, you can list the alert rule by clicking on the refresh button.

We can further go and stop the virtual machine to test the alert setup. Moreover, you will receive the alert SMS on the notification channel setup for this notification.

Further the virtual machine will be restarted as per the action defined in action group.


Not to mention, Microsoft Azure Monitor provides you a platform for tracking and monitoring the performance of your apps and systems, and other resources.

Happy Learning!!


Written by 

Sunil is a technology enthusiast Devops Engineer with overall experience of 9 years. He possesses deep experience with CI/CD development, AWS and Google Cloud platforms, Kubernets,Docker and other Devops practices.

1 thought on “Azure Monitor: How to setup alert and actions?4 min read

Comments are closed.