• EnglishEspañol日本語한국어Português
  • Log inStart now

PHP agent and Heroku

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:

Within a few minutes, data should start appearing in your APM Summary page. If no data appears, see the verification and troubleshooting procedures in this document.

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:

  1. Download a "clean" copy of newrelic.ini_.heroku [INI | 16KB].

  2. Rename the file from newrelic.ini_.heroku to newrelic.ini.

  3. Copy newrelic.ini to the root directory of your project repository.

  4. Customize your settings as described in PHP agent configuration.

    Caution

    Do not change newrelic.license, newrelic.loglevel, or newrelic.appname. These settings are configured by Heroku toolbelt.

  5. Commit your config file changes to your repository, and push your changes to Heroku.

  6. 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.

  1. To name your application, run this Heroku toolbelt command:

    bash
    $
    heroku config:set NEW_RELIC_APP_NAME='YOUR_APP_NAME'
  2. 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:

NEW_RELIC_APP_NAME=YOUR_APP_NAME

Verify your installation

To verify that Heroku has installed the New Relic add-on, run this Heroku toolbelt command:

bash
$
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.

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.

  1. To view the web server log, run this Heroku toolbelt command:

    bash
    $
    heroku logs -t | tee newrelic.log
  2. Use the log file to troubleshoot the issue.

  3. 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:

bash
$
heroku config:set NEW_RELIC_LOG_LEVEL=verbosedebug

Caution

The 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:

bash
$
heroku config:unset NEW_RELIC_LOG_LEVEL

Did this doc help with your installation?

Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.