Connection problem to Application Insight from NodeJs

11/18/2020

I have a kubernetes Cluster, with Istio.

Inside Pod y have a nodejs project, with App Insight configured

appInsights
.setup(process.env.APP_INSIGHT_INSTRUMENTATION_KEY)
.setAutoDependencyCorrelation(true)
.setAutoCollectRequests(true)
.setAutoCollectPerformance(true, true)
.setAutoCollectExceptions(true)
.setAutoCollectDependencies(true)
.setAutoCollectConsole(true)
.setUseDiskRetryCaching(true)
.setSendLiveMetrics(true)
.setDistributedTracingMode(appInsights.DistributedTracingModes.AI)
.start();

When y test in local work fine, the problem is when I upload the project to k8s, i have connection refuse.

ApplicationInsights:CorrelationIdManager [ Error: connect ECONNREFUSED 40.71.13.169:443 at TCPConnectWrap.afterConnect as oncomplete at TCPConnectWrap.callbackTrampoline (internal/async_hooks.js:126:14) { errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '40.71.13.169', port: 443 } ]

that could be happening?

-- mpanichella
azure-application-insights
istio
kubernetes

1 Answer

11/24/2020

You need to allow outbound connection to IP addresses used by Application Insights and Log Analytics from your firewall. Not sure if you are hosting your Kubernetes cluster in Azure. If yes, it would be Network Security Group attached to the VNET of the cluster where you can allow Virtual network service tags for 'AzureMonitor' outbound connection to avoid hard dependency on IP addresses.

Also since you are using Istio, make sure you allow egress from the mesh (though by default should be enabled in the proxy).

-- krishg
Source: StackOverflow