Custom Alerts in Application Insights

March 07, 2024

In this earlier post I cover creating alerts in App Insights and, previously, here I have covered adding custom metrics.

In this post, I’m going to cover the idea of creating a Kusto query and then create an alert off the back of that.

The Query

To start with, let’s test the query. The specific custom metric that I have is called SearchCounter. This is basically a custom metric (from the above post) that counts the number of times a search on my site has been executed.

It’s actually quite easy to see the data against custom metrics; it’s from a table called, confusingly, customMetrics:


You can then use a query such as the following to return a sum over a period:

|where name == "SearchCounter"
|summarize TotalSearches = sum(value)

This returns something like this:



When an alert is created, you can specify a custom log search:

New Alert

You can measure by either the total number of rows returned, or by any summarized value:

New Alert

Finally, in the alert logic (further down the same page), you can specify a threshold. I’ve specified 10, and then in the alerts window, you should see when the alert fires:

Alert Fires

It’s worth bearing in mind that the alert doesn’t have to actually do anything to fire - it will simply fire and tell you it’s done so.


Microsoft Tutorial

Profile picture

A blog about one man's journey through code… and some pictures of the Peak District

© Paul Michaels 2024