Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

Using the PHP Agent with Heroku


#1

Heroku Overview

Heroku’s Platform-as-a-Service model runs as well as configures your host. Many of the regular configuration options in the PHP Agent aren’t available in Heroku, so this should help troubleshoot or configure the agent in your Heroku environment.

Logging

Normally, the logs for the PHP Agent are found at /var/log/newrelic/, but Heroku routes all logs to STDERR. You can gather logs with Heroku with the following commands:

Linux: heroku logs -t | tee newrelic.log

Windows: heroku logs -t > newrelic.txt

Please note, these commands print out new log entires, therefore it won’t capture events that occurred before the command was written. You will also see all Heroku logs, and not just New Relic related entries.

Restarting the Daemon

Instead of restarting the daemon or restarting your PHP dispatcher after any config changes are made, you’d rebuild your slug in Heroku. Every time you push your repo, the slug compiler will rebuild from the buildpack. If the daemon disappears and the application stops reporting data you can rebuild your slug.

If pushing an empty commit isn’t something you’d like to do, you can use the Heroku repo tool.

Environment Variables

The most common way to configure the PHP agent on Heroku is to set environment variables, either by using the Heroku CLI:

heroku config:set NEW_RELIC_LOG_LEVEL=verbosedebug

or by setting them manually via the web interface, found under Settings > Config Variables

The following environment variables are used by the buildpack when building the newrelic.ini :

NEW_RELIC_APP_NAME

NEW_RELIC_LOG_LEVEL

NEW_RELIC_LICENSE_KEY

NEW_RELIC_CONFIG_FILE

All other settings will need to be set either uploading a custom configuration file named .user.ini , or pointing NEW_RELIC_CONFIG_FILE at another file in the repo.

.user.ini

If there are any custom settings that need to be added or modified, it is best to add them in a per directory .user.ini file. In the standard Heroku buildpack, any settings in this file will be automatically copied to ext-newrelic.user.ini .

Note: If your root directory’s git repository is also the root directory of your website, any files placed in this directory will also be served up by default. Therefore setting up a newrelic.ini and pointing NEW_RELIC_CONFIG_FILE isn’t advised.

Heroku Pipelines

If you just installed the agent with Heroku Pipelines but aren’t seeing it in the APM UI, please be sure to install the add-on to your staging app, NOT your production one. Once added, the New Relic add on should move between pipelines when getting promoted to a production or development app.

If you’re still not able to see your application in the APM UI if it’s been installed on your staging application, it may be worth contacting Heroku support. There aren’t any configuration changes going on with New Relic during these steps, so we wouldn’t have further insight on what to look into next.