Monitoring Nodejs application with Azure Application Insights

Sai 1 Reputation point
2020-12-15T08:33:33.283+00:00

We are trying to monitor a nodejs application through azure application insights. We are following MS docs - https://learn.microsoft.com/en-us/azure/azure-monitor/app/nodejs even after going though we don't find much luck as we don't see any of the application metrics like users / sessions in application insights.

Please can you guide us on the same.

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,202 questions
{count} votes

2 answers

Sort by: Most helpful
  1. kobulloc-MSFT 26,246 Reputation points Microsoft Employee
    2020-12-17T08:12:16.453+00:00

    Quick Note:
    If you are only missing some telemetry like users and sessions, make sure that you have client side code in addition to your server side code:

    https://learn.microsoft.com/en-us/azure/azure-monitor/app/usage-overview#send-telemetry-from-your-app

    How to get things working
    Here is the basic setup for a minimalistic Application Insights setup with Node.js:

    1. Quickstart: Create a Node.js web app in Azure
      https://learn.microsoft.com/en-us/azure/app-service/quickstart-nodejs?pivots=platform-windows
    2. Monitor your Node.js services and apps with Application Insights
      https://learn.microsoft.com/en-us/azure/azure-monitor/app/nodejs

    Key points:

    • Be sure to run: npm install applicationinsights --save
    • Be sure to include this in your code: let appInsights = require('applicationinsights');

    For this, I modified the line of code above using a great blog from Kenichiro Nakamura
    which has the following:

    const appInsights = require("applicationinsights");  
    appInsights.setup("<instrumentation_key>");  
    appInsights.start();  
    

    Kenichiro's blog is a great resource and I would recommend reading it in addition to the documentation:
    https://dev.to/kenakamu/application-insights-sdk-for-node-js-3ki1

    You will see something like this:

    Screenshot of Nodejs hello world.png

    Screenshot of Application Insights telemetry.png

    Troubleshooting
    If things aren't working out the way you expect them to, there is a troubleshooting guide for Application Insights that addresses many of the common issues:

    ASP.NET troubleshooting (includes some generic troubleshooting tips):
    https://learn.microsoft.com/en-us/azure/azure-monitor/app/asp-net-troubleshoot-no-data

    If you are still running into issues, message us and let us know. We will ask you for some information so that we can further investigate things on our end.

    1 person found this answer helpful.
    0 comments No comments

  2. Hao9008 1 Reputation point
    2020-12-23T12:58:38.177+00:00

    Hi @Anonymous ,

    I try out the sample with a 3rd party logging component Winston. I saw a lot of statement showing that I need to setup appInsight even before I start to load any 3rd party component. Below is a piece of my code sample:

    50863-image.png

    1. imported the SDK
    2. setup the instrument key
    3. start the service for logging all the telemetry

    But I encountered issue such as the outgoing port unreachable:
    50825-image.png

    If I tried to add the endpoint URL:
    50845-image.png

    I will still encounter the same error, but with a different outgoing port IP.
    I look through the Microsoft doc and know that both IP is somehow related to the server outgoing port but I wasn't sure and understand what is the meaning of it. Would you mind explain a little bit of that.
    50719-image.png

    I would like to seek some advice from you as I have been facing this issue for months and still couldn't get any breakthrough. A lot of sample looks straightforward as how I did it but non of them show any information regarding the outgoing port unreachable issue.

    Thanks


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.