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 New Relic APM, Browser, and Insights.
This document describes special considerations for using Heroku as a hosting service with New Relic's Node.js agent.
Install the New Relic 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.
From Heroku's Add-on page for New Relic, select the appropriate subscription plan. Then run this toolbelt command:
heroku addons: create newrelic:$planlevel
- From Select an app, select your New Relic app.
Use this toolbelt command to give your app a descriptive name:
heroku config:set NEW_RELIC_APP_NAME='Your Application Name'
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:
heroku config:set NEW_RELIC_NO_CONFIG_FILE='true'
Install the Node.js agent and save to your npm dependencies.
npm install newrelic --save
To ensure that the newrelic package is properly included in your package.json file when you push to Heroku, install the New Relic Node.js agent package on your local system. Include New Relic on the first line of your app's main module:
Run the following commands:
git add . && git commit -m "Add New Relic" git push heroku master && heroku logs --tail
- Restart your dyno.
- 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 Overview 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.
$ 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_APDEX=0.010 $ heroku config:set NEW_RELIC_NO_CONFIG_FILE='true'
To confirm your settings from the command line, use:
$ 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:
npm install newrelic --save
For more help
Additional documentation resources include: