App Insights Alert can trigger Azure Webhook which helps automating self-healing of the issue; read about it in next blog.
In last blog, we looked at customised query for Performance Counters. In this, we will have hands on setting up Microsoft Azure Application Insights (here after called App Insights) Alert(s). Below are the points which will be covered in this blog along with few Tips & Tricks from my experience.
- What is an Alert?
- How to create an App Insights Alert Rule?
- Business Case
- What is an Alert Rule?
- Custom Query using KQL
- Creating an Alert
- Configuring Signal Logic
- Action Groups
- Action Customisation
- How to manage existing App Insights Alert Rule(s)?
So without further ado, let’s get started
What is an Alert?
In the context of Microsoft App Insights, the “Alert” is a notification regarding some state of the Azure Service customer has enabled and using it which is shared with pre-defined recipients. An “Alert” can be just for the information or can be for potential upcoming issue/problem.
For example:
- Information Alert: Sending an Alert to the customer every Monday with previous week usage and billing details.
- Upscaling Alert: If %CPU is higher than threshold, upscale or increase instance of Web Server.
- Custom Alert: If %CPU is higher than threshold, send an actionable Alert to Support Team.
How to create an App Insights Alert Rule?
Each App Insights Alert needs to have Alert Rule setup. In this section, we will look at it step-by-step on setting up the Alert Rule. Also we will be looking at the purpose of the alert and how it will help business or customer to get ready for upcoming potential issue.
Business Case
Within last 5 minutes, if the count of failed HTTP Requests (not equal to 200) is more than 80, we want to notify Support Team so they can investigate on the cause of the issue and perform any corrective action.
System should check for failed HTTP Requests count every 5 minutes.
What is an App Insights Alert Rule?
To trigger an Alert, we need to define set of condition(s) or parameter(s). Combinations of these conditions / parameters are nothing but Alert Rule(s). App Insights Alert should have at least one condition or more.
From the above “Business Case”, we can extract below listed Alert Rules which will be setting up in next steps:
| Period: | Within last 5 minutes |
| Frequency: | Every 5 minutes |
| HTTP Request: | Failed (Status not equal to 200) |
| Threshold: | More than 80 |
Custom Query using KQL
In earlier blog, we have experienced on writing App Insights Custom Query using KQL.
For our “Business Case”, I have written simple KQL as below:
requests
| where timestamp > ago(5m) // filters last 5 minutes data
| where resultCode != 200 // filters failed HTTP Requests
| summarise count_value = count() // gets count of records & assigns to variable
| where count_value > 80 // filters based on threshold
Above KQL will become base for setting up other conditions for the Alert.
Creating an Alert

Once you run and validated your App Insights custom query along with expected result, “New alert rule” button gets enabled. Click on “New alert rule” button to open “Create Rule” screen.

By default “Condition” will be prefixed by red “!”/Exclamation. This indicates that all the conditions to setup an alert are not met. Click on the condition to open screen which allows to configure alert signal logic.
Configuring Signal Logic
Once we click on “Condition” under “Create Rule” screen, it opens “Configure Signal Logic” screen. Other remaining conditions to setup an Alert can be configured using this screen.

- Section: Alert Logic
- Based on
- Threshold value
- Section: Evaluated based on
- Period
- Frequency
Above are the most critical conditions to setup Alert correctly. Any small mistake or miscalculation can lead into wrong or invalid alert.
Section: Alert Logic
It is better you explore yourself on “Alert Logic” options to know more about each combinations.
This section allows us to define condition based on which the alert will be trigged. In our “Business Case”, if we have App Insights custom query result has more than 0 / Zero rows, we want alert to trigger.
Section: Evaluated based on
Alert “Period” and “Frequency” are very important conditions for the accuracy of the Alert.
This section of Configure Signal Logic screen help us define how frequently the alert should check for the data and for what period.
In our “Business Case”, we want it to trigger alert every 5 minutes and validate data of past 5 minutes.
Once you are done setting all these conditions, click on “Done” button to return back to “Create Rule” screen. At this point if everything is set properly under “Configured Signal Logic”, the red “!” / Exclamation under “Condition” section changes to green.
Action Groups
To notify respective groups/members with the result of the Alert, we can configure “Action Groups”. Action Groups is optional. Action Group can be one or more and each “Action Group” can have multiple recipient.
Action Customisation

Microsoft App Insights Alert provides few additional parameters so we can give personal touch and criticality of the Alert.
- Email Subject: Allows the define unique subject for email sent when alert gets triggered.
- Alert Rule Name: This should be unique as per App Insights and helps searching alert in future for editing and fine tuning.
- Severity: Helps define criticality of the Alert
After all these parameters or conditions if all goes well, you can click on “Create alert rule” button to create an Alert.
How to manage existing App Insights Alert Rule(s)?

Oh! It is very simple…
- Under App Insights – Monitoring, click on “Alerts”
- Click on “Manage alert rules” to open a screen which lists all the Alert Rules setup within current App Insights
- Find the Alert Rule based on name and other available filter options
- Click on the Alert Rule name to open Alert Rule in edit more
Again, I am not expert on this context. I am just sharing what I have explored and have learnt. If you think you know something, don’t hesitate to share in Comments.
