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.
From Heroku's Add-on page for New Relic, select the appropriate subscription plan. Then run this toolbelt command:
bash$heroku addons:create newrelic:$planlevelFrom Select an app, select your New Relic app.
Use this toolbelt command to give your app a descriptive name:
bash$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:bash$heroku config:set NEW_RELIC_NO_CONFIG_FILE='true'Verify your New Relic app name, , and log setting:
bash$heroku configInstall the Node.js agent and save to your
npm
dependencies.bash$npm install newrelic --saveTo ensure that the
newrelic
package is included in yourpackage.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.jsRun the following commands:
bash$git add . && git commit -m "Add New Relic"$git push heroku master && heroku logs --tailRestart 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 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.
$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:
$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