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 Tenant 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>
Important: If you use npm 12 or later, npm does not run dependency install scripts unless they are explicitly approved. Before upgrading to npm 12, use npm 11.16 or later to review pending install scripts:
npm approve-scripts --allow-scripts-pending
Approve the AppDynamics agent install script if you trust it:
npm approve-scripts appdynamics
Commit the updated package.json so future installs can run the approved agent install script.
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.