I've enabled application insights on an Azure WebApp that I created. My WebApp is calling a third party API which runs on a quota. I am only allowed 100k calls per month.
I need to track those API calls so that I can create an alert when the number of calls has reached 50%, then another alert 75%.
I am using TrackEvent every time the call is made and the event in the AppInsights dashboard does increment. But I can't seem to create an alert when a certain number of calls is made. I can't see it from the list of 'events' dropdown.
Also in addition, one other requirement that I need is to create an alerts when the number of calls to the goes over 10 per minutes.
Is TrackEvent the right method to use for these requirements?
I did something like this ...
var telemetryEventClient = new Microsoft.ApplicationInsights.TelemetryClient(new Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration() { InstrumentationKey = "Instrumentation Key" });
telemetryEventClient.Context.Operation.Name = "MyAPIProvider";
var properties = new Dictionary<string, string>
{
{ "Source", "WebAppToAPI" }
};
var metrics = new Dictionary<string, double>
{
{ "CallingAPIMetric", 1 }
};
telemetryEventClient.TrackEvent("CallingAPI", properties, metrics);
but when I looked at setting up the alert and placed a threshold of 50000 (for testing, I just put 5), I never reach that as the event count is always 1. Am I approaching this the right way?