Skip to main content

NodeJS Nest

Installation

Following are the steps to install the New Relic agent and connect it with CubeAPM. If New Relic agent is already installed, you can jump to step 5.

  1. Install dependencies

    npm install newrelic
  2. (Optional) From node_modules/newrelic, copy newrelic.js into the root directory of your application.

  3. Configure the agent.

    exports.config = {
    app_name: ["<app_name>"],
    license_key: "ABC4567890ABC4567890ABC4567890ABC4567890",
    };
  4. Load the agent when the application starts.

    Add the following line at the top of your project's main file.

    const newrelic = require("newrelic");
  5. Tell the agent to connect with CubeAPM instead of New Relic:

    exports.config = {
    app_name: ["<app_name>"],
    license_key: "ABC4567890ABC4567890ABC4567890ABC4567890",
    host: "<domain_of_cubeapm_server>",
    };
    tip

    See Using CubeAPM with New Relic agents for details on how to set up <domain_of_cubeapm_server>.

Sample App

A working example is available at https://github.com/cubeapm/sample_app_nodejs_nest/tree/newrelic

Troubleshooting

The following can be used for troubleshooting:

exports.config = {
logging: {
// Print New Relic agent logs on screen
filepath: "stdout",
// Set New Relic agent log level to debug if needed to see detailed logs
level: "debug",
},
};