Monitoring your application with Application Insights
Nowadays, creating and publishing an application has become really easy. There are many different providers you could choose to host your app, either locally or in the cloud. This allows you to concentrate your efforts on providing a solution to meet the needs of the business.
'With great power, comes great responsibility.' What happens when your app has to be scaled for significantly larger numbers of users? What happens when an error is detected in the application? How can you monitor it?
Microsoft has created a really great product that helps you to answer all these questions; Application Insights.
With Application Insights you're able to monitor and proactively address errors within your application, creating a better experience for your users.
Microsoft has created this tool, so you might think that it will only monitor Microsoft technologies, but you'd be wrong. You can monitor apps created usingMicrosoft stack, as well asNode JSandJavaapps.
The Application Insights portal includes a useful and customizable dashboard providing you with actionable data.
Specific exception details, including the stack trace
In addition, the tool allows you to create alerts so users will receive a notification whenever a specific condition is met. For instance: you could set an alert that’s triggered if your apps stop responding, or if your app takes more than X seconds to respond.
You might think that to have such detailed information you would have to make drastic changes to your current ap. That's not true!
As a first step, simply register in Azure (if you don't already have an account).
Then, create a new Application Insights resource.
After setting up successfully, go to theOverviewand copy theInstrumentation Key.
Now, in your Node application just run the following commands:
Add the Application Insights package
npm install applicationinsights --save
Start the monitoring service
const appInsights = require('applicationinsights');
After completing these steps, you'll see data coming to the Application Insights portal while users are using your app.
How cool is that?