Application Insight Alerts, why You don’t want to use them in some cases, especially “exception rate” metric.

Why we do not want to use all application insight alerts ?

Let create azure function like this:

const string Time = "0/60 * * * * *";
[FunctionName("FunctionName")]
public static void Run([TimerTrigger(Time)]TimerInfo myTimer, TraceWriter log)
{
  try
  {
    throw new Exception();
  }
  catch (Exception)
  {
  }
}

Also let create application insight alert with metric exception rate:

And now we will start to receive emails about alert fire up.

When we will dig into metric explorer we will see “0” exceptions but if we dig more and add exception rate metric we will see that it is more then “0”

And the reason of that is that the exception rate metric is also catching handled exceptions.

Exception rate is a system performance counter. The CLR counts all the handled and unhandled exceptions that are thrown, and divides the total in a sampling interval by the length of the interval. The Application Insights SDK collects this result and sends it to the portal.

From my point of view this do not make sense,

especially when there are cases in code when you can handle situations only by catching exceptions.

In summary we want to have all possible alerts setup but we should not use “exception rate” metric alert.

Here can find more about System performance counters in Application Insights

Leave a Reply

Your email address will not be published. Required fields are marked *