Monitoring critical API functionality

There are different cases when you want to check your API, like performance or availability. For most cases there are bunch of monitoring tools which will ping your API or logger which will report and error. But what to do if you want to monitor a partner/integration API which is supposed to call your API and register something like sales. Ideally you dont experience any issues, like performance or errors, all is green, but no sales for long period. Partner can be down or VPN can have troubles.
Lets setup an alert for API which should notify that something is wrong and there are no sales for long time using Application Insights in Azure.

Open AI Alerts of your WebApi

Create new alert and select resource which you want to monitor, which AI service.

The complicated part is to select the condition.
Create new condition and select  ServerRequests from menu

There you can specify a customer query which will check in AI logs for any endpoint you want to monitor

In this case it will check for API which contains "sale". Sample query
requests | extend itemType = iif(itemType == 'request',itemType,"") | where (itemType == 'request') | where * has 'sale'

Set the timing and alert logic. In this case it will alert if there is no sales during last 15 minutes

The remaining part is just add or create an Alert group where you can specify Email, SMS or Webhook parameters to deliver the alert.


Popular posts from this blog

Testing Azure Functions locally with automated integration test

Running Stockfish hosted in Azure function

Consuming Web API using JavaScript and XMLHttpRequest method