Monitoring Nodejs application with Azure Application Insights

Sai 1 Reputation point

We are trying to monitor a nodejs application through azure application insights. We are following MS docs - 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.
1,927 questions
{count} votes

2 answers

Sort by: Most helpful
  1. kobulloc-MSFT 13,586 Reputation points Microsoft Employee

    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:

    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
    2. Monitor your Node.js services and apps with Application Insights

    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");  

    Kenichiro's blog is a great resource and I would recommend reading it in addition to the documentation:

    You will see something like this:

    Screenshot of Nodejs hello world.png

    Screenshot of Application Insights telemetry.png

    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):

    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.
    No comments

  2. Hao9008 1 Reputation point

    Hi @kobulloc-MSFT ,

    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:


    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:

    If I tried to add the endpoint URL:

    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.

    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.