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.
After deploying your PHP app on Heroku, install our PHP agent:
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.ini_.heroku to newrelic.ini.
Copy newrelic.ini to the root directory of your project repository.
Customize your settings as described in PHP agent configuration.
Do not change newrelic.license, newrelic.loglevel, or 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:heroku config:set NEW_RELIC_CONFIG_FILE=newrelic.ini
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:
heroku config:set NEW_RELIC_APP_NAME='YOUR_APP_NAME'
To verify your app's name change, run:heroku run env | grep NEW_RELIC_APP_NAME
Verify that the confirmation prompt returns the new app name:
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:
NEW_RELIC_LICENSE_KEY='YOUR_LICENSE_KEY' NEW_RELIC_LOG_LEVEL="warning" NEW_RELIC_APP_NAME="YOUR_APP_NAME"
You can also use phpinfo to verify that your app is being instrumented.
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: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