Heroku is a Platform as a Service (PaaS) solution for hosting web applications in various agent languages, including Ruby. With New Relic, you can extend Heroku using APM and Browser metrics. This page describes special considerations for using Heroku as a hosting service with New Relic's Ruby agent.
After deploying your Ruby 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. New Relic will begin monitoring application performance, end user experience, and app server performance collected after the add-on is installed. Within a few minutes, data should start appearing in your APM summary page.
If New Relic is already installed, reinstall the add-on using the Heroku toolbelt command.
heroku config:set NEW_RELIC_APP_NAME='Your Application Name'
You can configure New Relic in your
newrelic.yml file, or you can use environment variables to take precedence over the values in your config file. Use
heroku config:set to modify the agent's settings for your Heroku appication.
For example, to set the
analytics_events.max_samples_stored setting to 500:
heroku config:set NEW_RELIC_ANALYTICS_EVENTS_MAX_SAMPLES_STORED=500
Knowing which data came from which host allows you to filter the metrics displayed in the UI to a specific host. On Heroku, hostnames within dynos are dynamically generated and not generally meaningful to you as an application developer.
Starting in version 3.9.5, the Ruby agent reports the Heroku dyno name as the hostname (for example,
web.1). This allows you to view your data scoped to a particular dyno name. You can disable this behavior by setting the
heroku.use_dyno_names setting to
false. The agent will then use a single aggregated placeholder name called
Some dynos have names that are dynamically generated, and these may take on many unique values over time. Examples include
scheduler dynos created by the Scheduler add-on, and
run dynos created by invoking
heroku run on the command line. In order to keep the number of unique hostnames reasonable, the Ruby agent will automatically aggregate data from
run dynos into hostnames called
If you have other dyno types that are dynamically created, use the
heroku.dyno_name_prefixes_to_shorten configuration setting to apply the same aggregation to these other dyno types.
On Heroku, the Ruby agent logs to standard output, mixing agent logs with your normal application logs. Log entries generated by the Ruby agent include a
[NewRelic] tag as a prefix.
To retrieve logs on Heroku:
Verify that your
NEW_RELIC_LOGenvironment variable is set to
stdoutwith this Heroku toolbelt command:heroku config
To reset the environment variable if necessary, run:heroku config:set NEW_RELIC_LOG="stdout"
newrelic.ymlfile in an editor.
debugand save the file. Be sure you do not modify the indentation.
Restart your web app.
Generate some traffic to your app and run it for about five minutes.
Run the following Heroku toolbelt command to view logs only from the New Relic agent:heroku logs -n 1500 | grep -i relic
If sending your log file to New Relic Support, attach the log file to your support ticket, along with
newrelic.ymlagain, and change the
log_levelto the previous setting. Save the file.
Additional documentation resources include: