• EnglishEspañol日本語한국어Português
  • Log inStart now

Node.js agent and Heroku

Heroku is a Platform as a Service (PaaS) solution for hosting web applications in various agent languages, including Node.js. With New Relic, you can extend Heroku with metrics from and .

Here we describe special considerations for using Heroku as a hosting service with New Relic's Node.js agent.

Install the agent add-on

After deploying your Node.js app on Heroku, install the New Relic agent. Installing the add-on automatically creates a private New Relic account and configures access for Heroku servers.

To install the New Relic add-on through the Heroku website's Add-on page for New Relic, you must be logged in to Heroku.

  1. From Heroku's Add-on page for New Relic, select the appropriate subscription plan. Then run this toolbelt command:

    bash
    $
    heroku addons:create newrelic:$planlevel
  2. From Select an app, select your New Relic app.

  3. Use this toolbelt command to give your app a descriptive name:

    bash
    $
    heroku config:set NEW_RELIC_APP_NAME='Your Application Name'
  4. If you are using environment variables instead of your newrelic.js config file settings to customize your Node.js agent configuration, use this toolbelt command:

    bash
    $
    heroku config:set NEW_RELIC_NO_CONFIG_FILE='true'
  5. Verify your New Relic app name, , and log setting:

    bash
    $
    heroku config
  6. Install the Node.js agent and save to your npm dependencies.

    bash
    $
    npm install newrelic --save
  7. To ensure that the newrelic package is included in your package.json file when you push to Heroku, install the package for New Relic Node.js agent on your local system. Use Node.js -r/--require flag when you run your program to make sure New Relic's module is loaded:

    bash
    $
    node -r newrelic YOUR_PROGRAM.js
  8. Run the following commands:

    bash
    $
    git add . && git commit -m "Add New Relic"
    $
    git push heroku master && heroku logs --tail
  9. Restart your dyno.

  10. Generate some traffic to your app.

New Relic will begin monitoring application performance, end user experience, and host performance collected after the add-on is installed. Within a few minutes, data should start appearing in your APM Summary page.

Troubleshoot your installation

If no data appears within a few minutes after you complete the installation procedures, follow the Node.js agent troubleshooting procedures.

Customize your configuration

You can customize the New Relic newrelic.js config file for your Node.js agent. You can also use New Relic's Node.js agent environment variables in the Heroku environment to override your config file values.

Here is an example of using the Heroku command line to set environment variables instead of using your newrelic.js config file.

bash
$
heroku config:set NEW_RELIC_LICENSE_KEY=your license key
$
heroku config:set NEW_RELIC_APP_NAME=your production app name
$
heroku config:set NEW_RELIC_NO_CONFIG_FILE='true'

To confirm your settings from the command line, use:

bash
$
heroku config

Upgrade from an existing New Relic installation

To upgrade your Node.js agent version if New Relic is already installed, use this toolbelt command:

bash
$
npm install newrelic --save
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.