Install the Node.js Agent
To install the agent, run the install command in the directory of your application and add a
require
command to add the agent module to your application.
If you are using Node.js 0.8.1 through 0.8.18, see Set User Agent for Node.js 0.8.1 through 0.8.18 before running the install command.
Install via npm
Refer to Agent and Controller Compatibility to determine which versions of the Node.js Agent are compatible with your Controller.
To install the latest agent, run the following command:
npm install appdynamics@next
If you know which specific version of the Node.js agent you want to install, you can specify it:
npm install appdynamics@<x.y.z>
If you are using npm 5, you must disable the lock file by setting package-lock=false
The version of npm that ships with Node.js v6 does not automatically run post-install scripts used by 4.5.12 and later versions of the agent. Cisco AppDynamicsrecommends using the latest Node.js version.
If Node.js v6 must be used, npm needs to be updated prior to installing the agent:
npm install -g npm
npm install appdynamics
Add the Require Statement
Paste the following require statement as the very first line of your application source
code before any other require statement. Then, replace the variables with the values for
your setup. To find your account name and access key, select Settings
and then
License.
require("appdynamics").profile({
controllerHostName: '<controller host name>',
controllerPort: <controller port number>,
controllerSslEnabled: false, // Set to true if controllerPort is SSL
accountName: '<AppDynamics_account_name>',
accountAccessKey: '<AppDynamics_account_key>', //required
applicationName: 'your_app_name',
tierName: 'choose_a_tier_name',
nodeName: 'choose_a_node_name'
});
For reference information on the settings, along with other settings you can use, see Node.js Settings Reference.
You can place the require
In this case, you would need to modify your point-of-entry source file; this it can be just a single line to the require() require(“<script-that-initializes-the-agent>” profile()
If it is not possible to place the require statement as the first line of code, you can insert the statement elsewhere, but it must occur before the require() require(“appdynamics”)
Test the Configuration
To verify the installation, restart the application and put load on it. The new node should appear in the flow map for the business application you specified in the configuration.