User Documentation


Get your license key Anchor to this heading

Sign up at and get your license key.

Add your license key Anchor to this heading

Add your New Relic license key as an environment level variable:

platform variable:create --level environment --environment '<your-environment>' --visible-build false --inheritable false env:NEW_RELIC_LICENSE_KEY --value '<your-new-relic-license-key>'

Give your application a name Anchor to this heading

Add a new environment level variable to give your application a recognizable name:

platform variable:create --level environment --environment '<your-environment>' --visible-build false --inheritable false env:NEW_RELIC_APP_NAME --value '<your-application-name>'

Configure the New Relic logs Anchor to this heading

Our File System being read-only, New Relic won’t be able to create its log file. To allow New Relic to output logs, we need to get a writeable directory to put the log file in.

At the end of the build hook in your, create a newrelic directory in your application root:

    # ... your hooks
    build: |
        # ... your build hook
        mkdir $PLATFORM_APP_DIR/newrelic        

Now add this directory to your mounts:

    # ... your mounts
        source: local
        source_path: newrelic

We now need to tell New Relic to use this file. To do that, create a new project level variable called NEW_RELIC_LOG:

platform variable:create --level project --visible-build false env:NEW_RELIC_LOG --value /app/newrelic/newrelic_agent.log

Set up the New Relic agent Anchor to this heading

Install the newrelic package:

npm install newrelic
# or
yarn add newrelic

Import it before any other import in your application’s main module:

// or
import "newrelic";

Commit and push the changes Anchor to this heading

$ git add -A
$ git commit -m "Enable New Relic"
$ git push

Once your environment is deployed and you’ve generated some traffic, you need to wait a little bit for your New Relic dashboard to be created.

Troubleshoot Anchor to this heading

You can check that your application is properly connected to New Relic by looking at the /app/newrelic/newrelic_agent.log file:

$ platform ssh
$ cat /app/newrelic/newrelic_agent.log

{"v":0,"level":30,"name":"newrelic","hostname":"api.0","pid":761,"time":"2021-02-03T16:12:50.890Z","msg":"Connected to with agent run ID xxxxx.","component":"collector_api"}
{"v":0,"level":30,"name":"newrelic","hostname":"api.0","pid":761,"time":"2021-02-03T16:12:50.890Z","msg":"Reporting to:","component":"collector_api"}
{"v":0,"level":30,"name":"newrelic","hostname":"api.0","pid":761,"time":"2021-02-03T16:12:50.892Z","msg":"Valid event_harvest_config received. Updating harvest cycles. {\"report_period_ms\":5000,\"harvest_limits\":{\"error_event_data\":8,\"analytic_event_data\":833,\"custom_event_data\":83}}"}
{"v":0,"level":30,"name":"newrelic","hostname":"api.0","pid":761,"time":"2021-02-03T16:12:50.897Z","msg":"Agent state changed from connected to started."}
{"v":0,"level":30,"name":"newrelic","hostname":"api.0","pid":761,"time":"2021-02-03T16:12:51.899Z","msg":"Starting initial 1000ms harvest."}

Is this page helpful?