mortb
mortb

Reputation: 9869

Email exceptions with stacktrace to dev team from application insights

In our older parts of our systems we have setup logging so that the dev team receives emails when an exception is thrown. The newer parts of our systems are hosted in azure and log errors to application insights. I've looked into application insights alerts, the alerts that can be setup to send email does however does not contain any information about the exception, or possibility to filter exceptions that are irrelevant.

So, given all the APIs available, I think that it should be possible to create emails that are more detailed. Does anyone have any information about the subject?

I can imagine creating a timer trigger function in Azure that would poll application insights API for errors at some interval and send emails, but creating it from scratch is a bit of a threshold.

Upvotes: 5

Views: 1886

Answers (2)

David
David

Reputation: 3157

I am using application insights for logging but combined with NLog for exception logging to a database and immediate emails with stacktrace. I could not get timely alerts from application insights for exceptions.

Upvotes: 3

Tiny Wang
Tiny Wang

Reputation: 16066

I have a java program, so I used java-appinsights-agent to collect metrics, requests, traces and send them to azure application insights instance. If you used other programming language, microsoft also provides other sdk or solutions.

enter image description here

I can provide suggestions on it if you needed. And let's start to create an alert rule here. You can also see this tutorial.

After setting the monitor to my program, I have my application insights instance which provides log analytics. Come to azure portal->your application insights instance-> logs, and let's focus on the exception. As we can see the screenshot below, app insights has caught exception message from my project. I queried all the exceptions here, it's supported to add some filters. Then I click New alert rule.

enter image description here

Next is setting the alert logic, any exception is important for me and I wanna know it as soon as possible, so if the query returns any exception(number of result > 0), the alert rule should be triggered, and the minimum interval for monitoring is 5 minutes here.

enter image description here

Next is adding action group, I'd like to create a new action group for my project, Add action groups-> create action group

enter image description here

After entering field in basic panel, let's focus on the Notification, see screenshot below:

enter image description here

At last, fill some field related to this rule and click create. Then I can receive email like the screenshot in the comment.

enter image description here

Upvotes: 2

Related Questions