Skip to content Skip to sidebar Skip to footer

Application Insights Alert Not Firing For Custom Metric

I have set up ApplicationInsights in my js code and whenever I send data to it, it is tracked correctly and I can see it in the portal. I want now to set up an email notification w

Solution 1:

the yellow triangle means "this event is active", and is true until the event's criteria are no longer true.

you might want to re-write this as a custom event, and submit the metric value in a call there, so you can see/search the custom event's details? metrics are not a searchable, so it would be hard to ever see the properties that way.

var properties = {
    Text: 'some text',
    Email: 'someemail@email.com'
};
var metrics = {
    UserFeedback: 1,
};
appInsights.trackEvent('User sent feedback', properties, metrics );

or something like that? (you don't need the date field, it is part of default telemetry for custom events)

As for why the alert is firing, i can never remember if the metric value is an average over the time period, or if that's a sum or something so that every time you submit 1 feedback, UserFeedback is constantly growing, so the alert value will never be back to 0?

The documentation for alerts is here: https://azure.microsoft.com/en-us/documentation/articles/app-insights-alerts/

and says:

•The period that you choose specifies the interval over which metrics are aggregated. It doesn't affect how often the alert is evaluated: that depends on the frequency of arrival of metrics.

• If no data arrives for a particular metric for some time, the gap has different effects on alert evaluation and on the charts in metric explorer. In metric explorer, if no data is seen for longer than the chart's sampling interval, the chart will show a value of 0. But an alert based on the same metric will not be re-evaluated, and the alert's state will remain unchanged.

• When data eventually arrives, the chart will jump back to a non-zero value. The alert will evaluate based on the data available for the period you specified. If the new data point is the only one available in the period, the aggregate will be based just on that.

i believe it is that second and third bullets there are getting you. you've set the value to 1, because you sent the metric. but if nobody ever sends a 0 value for that metric, the alert rules never see the value change again. you might have to do a second trackMetric("UserFeedback", 0, ... ) after your initial call so that the alert goes away? (and then set your threshold to like .5 instead of 1?)

But i'd still send any details with a custom event so you can actually see them.

Post a Comment for "Application Insights Alert Not Firing For Custom Metric"