APM Insight Node.js agent shows “extraneous” — monitor not onboarded

APM Insight Node.js agent shows “extraneous” — monitor not onboarded

Scope: The standard install is in the installation guide (unzip, npm install, require('apminsight') first line, apminsightnode.json fields). This article covers only why a finished install can still be extraneous — typically on servers with no outbound internet, such as EC2 in a private subnet.

Symptom

npm list apminsight shows the package as extraneous. The monitor is missing in Applications Manager, or present with no transactions. Re-running the install, or using sudo, does not help.

myapp@1.0.0 /opt/myapp
└── apminsight@5.1.2 extraneous -> ./../apm_agent/agent_minified

Cause

extraneous = the package is on disk but not listed in the application's package.json, so require('apminsight') never loads it and instrumentation never starts.

npm install <folder> saves that entry by default (npm 5+). If it is missing, the install did not finish correctly:

TriggerWhat happens
Run from inside agent_minified, not the app rootnpm saves to the agent's package.json; app untouched
Run with sudofiles owned by root; the app user cannot use them
No outbound internetnpm still calls registry.npmjs.org / nodejs.org → ECONNRESET / ETIMEDOUT (or ENOTEMPTY), rolls back, saves nothing — a stray symlink remains, shown by ->
No package.json in that environmentnothing for npm to link against

Fix

Run as the application user, without sudo. Follow the install guide, with the changes below.

1. Clear old copies

sudo rm -rf /<application_root>/node_modules/apminsight
sudo rm -rf ~/node_modules/apminsight
sudo chown -R <app_user>:<app_user> <Agent_unzipped_path>/

2. Install offline, from the application root

cd /<application_root>
npm install <Agent_unzipped_path>/agent_minified --offline

--offline = cache only, never the network. The agent is fully bundled, so nothing needs downloading — this is what makes it work on an isolated host.
Example: unzipped to /opt/apm_insight_agent_nodejs → install /opt/apm_insight_agent_nodejs/agent_minified.

3. Check package.json — step 2 writes this itself:

"apminsight": "file:../<Agent_unzipped_path>/agent_minified"
grep -n apminsight package.json

Empty? The install failed — review the step 2 output before adding the line by hand.

4. Verify — restart the application using whatever method normally starts it (service manager, process manager, container restart, or start script). It must be a full process restart: the agent is loaded by require('apminsight') when the entry file executes, so a hot reload that does not re-run it will not pick up the agent. Then:

npm list apminsight          # no "extraneous"
ls -l /<application_root>/apminsightdata/logs
nc -vz <apm_host> 8443

In Applications Manager check the last 24 hours — the default 30-minute view looks empty right after onboarding.

If npm list is clean but no monitor appears, the agent is loading correctly and the problem is elsewhere — it cannot reach Applications Manager. Check /<application_root>/apminsightdata/logs for:

[ERROR] Error while getting IP from hostname : Error: getaddrinfo ENOTFOUND <apm_host>

That means the application server cannot resolve the name set as apmHost. This is internal name resolution on that server (DNS or /etc/hosts) — unrelated to npm or to outbound internet access. Correct name resolution, or set apmHost to the Applications Manager server's IP as a workaround. Also confirm apmPort matches the server's SSL port (8443 by default); a non-SSL port will fail the connection handshake. See Monitor not getting added.

If it still fails, collect

  • /<application_root>/apminsightdata/ — the complete logs directory
  • /<application_root>/apminsightnode.json
  • Output of npm list apminsight
  • Complete npm install output, plus ~/.npm/_logs/<latest>-debug-0.log

References