AppDynamics Application Intelligence Platform
3.9.x Documentation
To use the AppDynamics Node.js Agent, you need an AppDynamics account on a running v3.9+ controller.
You can use the AppDynamics SaaS controller. If you do not already have an account on the SaaS controller you can sign up for a subscription here.
Or you can use an on-premise controller that is installed at your site. You can download an on-premise controller from here, and then follow these instructions on how to install it.
You need to know the controller host and port to complete the agent installation. Check your welcome email from AppDynamics for the host and port if you signed up for a SaaS account.
You need write access to the Node.js project.
To install the latest version you can run 'npm install appdynamics' for each application you want to monitor, but we recommend matching the agent version to your AppDynamics Controller version:
npm install appdynamics@<version>
For example, if your AppDynamics controller version is 3.9.0, we recommend installing the 3.9.0 Node.js Agent:
npm install appdynamics@3.9.0
Then paste the following in your application as the very first line of your application source code, before any other require statement. Replace the variables with the values for your setup:
require("appdynamics").profile({ controllerHostName: '<controller host name>', controllerPort: <controller port number>, controllerSslEnabled: false, // Set to true if controllerPort is SSL accountName: 'AppDynamics_account_name', // Required for SaaS accounts accountAccessKey: 'AppDynamics_account_key', // Required for SaaS accounts applicationName: 'your_app_name', tierName: 'choose_a_tier_name', nodeName: 'choose_a_node_name', });
Stop and restart your application.
Run some traffic through the application.
Wait a few minutes.
Log into your controller.
Select the newly instrumented application.
You should see metrics reported in the flow maps.
This is the complete list of settings in the require statement that you insert into your application code. Not all these settings are required.
btEntryPointDelayDisabled: true|false - Optional: defaults to false. Setting to true can accelerate the startup of business transactions, but it can adversely affect drilldown in distributed transactions.
maxProcessSnapshotsPerPeriod: integer - Optional: defaults to 2. Number of automatic process snapshots allowed in processSnapshotCountResetPeriodSeconds seconds (see below).
processSnapshotCountResetPeriodSeconds: Optional: defaults to 60. Frequency, in seconds, at which the automatic process snapshot count is reset to 0.
debug: true|false - Optional: defaults to false. Turn this option on for logging and troubleshooting.
If your Node.js version is between 0.8.1 and 0.8.18 inclusive, you need to set the user-agent npm property before you run the npm install command. The syntax is:
npm config set user-agent "node/<version> {linux|darwin} {x64|i86}"
For example:
npm config set user-agent “node/v0.8.14 linux x64"
If you are launching a cluster of Node.js processes to implement your app, add the appdynamics require statement to the master process code and to the code of each of the worker processes.
If you cannot obtain a 3.9 controller, it is possible to get started using the agent with a 3.8.6 controller, until you can upgrade. For more information, contact omed@appdynamics.com for information on how to do this.
If you are trying to install the Node.js Agent on a version of Node.js that the agent does not support, the installation will fail and you will see a message similar to the following:
npm ERR! notsup Unsupported npm ERR! notsup Not compatible with your version of node/npm: appdynamics@3.9.3 npm ERR! notsup Required: {"node":">=0.8.0 <=0.10.31"} npm ERR! notsup Actual: {"npm":"1.4.28","node":"0.10.32"} npm ERR! System Linux 2.6.18-348.16.1.el5 npm ERR! command "<your command>" npm ERR! cwd <path> npm ERR! node -v v0.10.32 npm ERR! npm -v 1.4.28 npm ERR! code ENOTSUP npm ERR! npm ERR! Additional logging details can be found in: npm ERR! <path>/npm-debug.log npm ERR! not ok code 0
Check the AppDynamics release notes to find out the latest Node.js version supported by the agent.
If you need an agent for an unsupported version, contact AppDynamics Support about getting an agent for 0.8.X and 0.10.X versions of Node.js that is compatible with your environment.
There is an agent log and a proxy log for each application.
If the agent is running in debug mode, the agent component logs to stdout/stderr. This log contains the transactions that the agent processes and sends to the proxy. This log is available in the same location to which stdout/stderr streams are directed from the monitored application.
If debug mode is not enabled, no agent log is generated.
You may set debug mode in the require statement that instruments your Node.js application. See Node.js Agent Settings.
The proxy logs the transactions that it accepts from the agent and sends to the Controller. The proxy generates logs whether or not the agent is running in debug mode.
When the agent component launches the proxy, it displays in the agent log the directory path to which the proxy is logging.
If you install the Machine Agent on the machine hosting the instrumented Node.js node and you specify the tier and node name in the machine agent's controller-info.xml file, the Node.js Agent will fail to register.
To avoid this problem:
2 Comments
Unknown User (youngsuk.ahnpark@pearson.com)
What if I want to make the instrumentation configurable?
I am using a config module (http://lorenwest.github.io/node-config/latest/index.html) which loads a json file to be used as configuration.
The use case is I am using the same code base to deploy in multiple environments: DEV, STAGING and PROD. We only have license for PROD.
Unknown User (omed.habib@appdynamics.com)
Hi Young,
You can use a config module to set the settings with no problem. You may want to have your Node.js app report to a different applicationName per environment and all other settings may be set the same.