Receive a notification when a metric value meets a condition
Azure Monitor makes metrics available for many Azure resources. These metrics convey the performance and health of those resources. In many cases metric values can point to something being wrong with a resource. You can create metric alerts to monitor for abnormal behavior and be notified if it occurs. This Quickstart steps through creating a Logic App, creating a job, and visualizing the metrics for the logic app. It then goes through creating an alert, and receiving a notification for a metric for the Logic App resource.
If you don't have an Azure subscription, create a free account before you begin.
Sign in to the Azure portal
Sign in to the Azure portal.
Create a Logic App
Click the Create a resource button found on the upper left-hand corner of the Azure portal.
Search for and select Logic App. Click the Create button.
Enter the name myLogicApp and the Resource Group myResourceGroup. Use your subscription. Use the default location. Check the Pin to Dashboard option. When complete, click Create.
The logic app should be pinned to your dashboard. Navigate to the logic app by clicking on it.
In the Logic App panel, select the Logic App Designer
Set up your values as seen in the following diagram.
In the designer, select the Recurrence trigger.
Set an interval of 20 and a frequency of second to ensure your logic app is triggered every 20 seconds.
Click the New Step button, and select Add an action.
Choose the HTTP option, and select HTTP-HTTP.
Set the Method as POST and the Uri to a web address of your choice.
It may take up to 5 minutes for the logic app run actions to occur.
View metrics for your logic app
Click the Monitor option in the left-hand navigation pane.
Select the Metrics tab, fill in the Subscription, Resource Group, Resource Type and Resource information for your logic app.
From the list of metrics, choose Runs Failed.
Modify the Time range of the chart to display data for the past hour.
You should now see a chart plotting the total number of runs your logic app has started over the past hour. If you do not see any, make sure you have waited at least 5 minutes from the step above. Then refresh your browser.
Create a metric alert for your logic app
In the top right portion of the metrics panel click the Add metric alert button.
Name your metric alert 'myLogicAppAlert', and provide a brief description for the alert.
Set the Condition for the metric alert as 'Greater than', set the Threshold as '10', and set the Period as 'Over the last 5 minutes'.
Finally, under Additional administrator email(s) enter your email address. This alert ensures that you receive an email in the event your logic app has more than 10 failed runs within a period of 5 minutes.
Receive metric alert notifications for your logic app
Within a few moments, you should receive an email from 'Microsoft Azure Alerts' to inform you the alert has been 'activated'.
Navigate back to your logic app and modify the recurrence trigger to an interval of 1 and frequency of hour.
Within a few minutes, you should receive an email from 'Microsoft Azure Alerts' informing you the alert has been 'resolved'.
Clean up resources
Other quick starts in this collection build upon this quickstart. If you plan to continue on to work with subsequent quick starts or with the tutorials, do not clean up the resources created in this quickstart. If you do not plan to continue, use the following steps to delete all resources created by this quickstart in the Azure portal.
From the left-hand menu in the Azure portal, click on Monitor.
Select the Alerts tab, find the alert you created in this quickstart guide and click on it.
In the metric alert panel, click Delete.
From the left-hand menu in the Azure portal, search for Logic App and then click Logic apps.
On the panel, click the logic app you created in this quickstart in the text box, and then click Delete.
In this quickstart, you’ve learned how to create a metric alert for your resources. For more information on metric alerts, click through to our overview on alerts.