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 in the Java proxy mode, run the following command:

npm install --appd_include_java_proxy=true appdynamics

To run the Node.js Agent on Windows with the Java proxy, see Run the Node.js Agent on Windows.

Add the Require Statement

Paste the following require statement as the very first line of your application source code before any other require statement. Replace the variables with the values for your setup. To find your account name and access key, select Settings Settings Icon 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',
proxy: true
});

For reference information on the settings, along with other settings you can use, see Node.js Settings Reference.

You can place the require statement as the first line in the require statement of another module that appears as the first line of code.

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() the file that you place the call to the agent into; for example, require(“<script-that-initializes-the-agent>”. You could also parameterize the profile() call to name different instances without having to have multiple versions of the agent initialization script.

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() of any core or third party module that needs to be instrumented. In general, the require(“appdynamics”) statement should occur as early as possible in the code.

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.