This is DYI post on how you can use Availability Tests and Data Access API together to enable most popular requests in Application Insights uservoice.
Application Insights uservoce has these 4 very popular items. It is not hard to implement them yourself using Application Insights extensibility points.
- Application Insights alert rule custom events
- Add alerts based on results of Analytics Queries
- Support alerting on a segmented/filtered metric
- Add support for calculated metrics to App Insights
Let’s start with the alert on segmented metric. Let’s say I want to recieve alert when nobody opens any posts on this site. Posts differ from the default and about page by
/blog/ substring in url. You can go to Application Insights Analytics and write a query like this to get the number of viewed posts:
1 2 3 4 5
Note also that I’m using 5 minutes in the past to allow some time for data to arrive. Typical latency for the telemetry is under the minute. I’m being on a safe side here.
In order to convert this query into a Pass/Fail statement I can do something like this:
1 2 3 4 5 6
This query will return a single value
1 2 3
Instead of a header you can pass api key as a query string parameter. Use the parameter name
&api_key. Resulting URL will look like this:
1 2 3
Final step will be to set up a ping test that will query this Url and make a content match success criteria to search for the keyword
You can change queries to satisfy other requests. You can query
name same way as I queried
url. You can set an alert when CPU is very high at least on one instance instead of standard averge across all instances:
1 2 3 4 5 6
You can also join multiple metrics or tables:
1 2 3 4 5 6 7 8
Some thoughts about this implementation:
- Availability tests runs once in 5 minutes from a single location. With 5 locations analytics query will run about every minute.
- The limit on number of analytics queries is 1500 per day. It allows to run a single ping test once a minute or more tests more rarely
- If query is too long you may need to use POST instead of GET. You can implement POST as multi-step test. But multi-step tests costs money. So you may be better off implementing a simple proxy that will run queries. Same way as I set certificate expiration monitoring.