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:
customMetrics
|where name == "SearchCounter"
|summarize TotalSearches = sum(value)
This returns something like this:
Alert
When an alert is created, you can specify a custom log search:
You can measure by either the total number of rows returned, or by any summarize
d value:
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:
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.