Heroku is a Platform as a Service (PaaS) solution for hosting web applications in various languages, including PHP. With New Relic, you can extend Heroku with metrics from and .
Prepare your application
Before installing the PHP agent, make sure your PHP web application is installed and running under Heroku. For more information, see Getting Started with PHP on Heroku.
Install the PHP agent
After deploying your PHP app on Heroku, install our PHP agent:
Configure the agent on Heroku
Heroku automatically configures default environment variables for your app. To customize your settings, create and upload a newrelic.ini file to Heroku:
Download a "clean" copy of
newrelic.ini_.heroku[INI | 16KB].
Rename the file from
newrelic.inito the root directory of your project repository.
Customize your settings as described in PHP agent configuration.
Do not change
newrelic.appname. These settings are configured by Heroku toolbelt.
Commit your config file changes to your repository, and push your changes to Heroku.
Instruct Heroku to use your customized config file via this Heroku toolbelt command:bash$heroku config:set NEW_RELIC_CONFIG_FILE=newrelic.ini
Name your application
To ensure that metrics from each app are reported separately, give each app a descriptive name. Your application name defaults to PHP Application on Heroku.
New Relic uses the app name to aggregate data. If you do not change this name, New Relic will aggregate the data from each additional PHP app you install under this same name.
To name your application, run this Heroku toolbelt command:bash$heroku config:set NEW_RELIC_APP_NAME='YOUR_APP_NAME'
To verify your app's name change, run:bash$heroku run env | grep NEW_RELIC_APP_NAME
Verify that the confirmation prompt returns the new app name:
Verify your installation
To verify that Heroku has installed the New Relic add-on, run this Heroku toolbelt command:
$heroku run env | grep NEW_RELIC
This will generate a list of New Relic environment variables in Heroku. The agent uses these environment variables to determine which account to report data to. You should see at least the following variables:
You can also use phpinfo to verify that your app is being instrumented.
Troubleshooting the agent on Heroku
To troubleshoot the PHP agent on Heroku, examine your log file, which is stored in the Heroku web server log.
To view the web server log, run this Heroku toolbelt command:bash$heroku logs -t | tee newrelic.log
Use the log file to troubleshoot the issue.
If you need further assistance, get support at support.newrelic.com.
The PHP agent defaults to the
warning log level. New Relic Support may also request logs at the
verbosedebug log level. To change the log level to
verbosedebug, run this Heroku toolbelt command:
$heroku config:set NEW_RELIC_LOG_LEVEL=verbosedebug
verbosedebug log level quickly generates a large volume of data. Use this setting only if New Relic Support requests it, and remove this setting as soon as you collect the output by running this Heroku toolbelt command:
$heroku config:unset NEW_RELIC_LOG_LEVEL