Search code examples
ruby-on-railsherokunewrelic

New Relic showing data from my local development environment and not the Heroku environment


So I have New Relic set up on my Rails app, which I run both locally for development and which I deploy to Heroku.

However, the New Relic dashboard shows data from my local setup and not from Heroku. I know because the data I can see corresponds to what's happening on the local environment, and on the new relic dashboard the listed servers includes the hostname of my local machine.

How do I make sure New Relic monitors the heroku environment instead?

New Relic is setup in my app this way:

  • 'newrelic_rpm" gem is included in the Gemfile
  • config/newrelic.yml exist and has been downloaded from the New Relic setup page
  • The license key in config/newrelic.yml is the one generated on the New Relic setup page
  • The heroku environment variables NEW_RELIC_APP_NAME and NEW_RELIC_LICENSE_KEY. The first one is the same name as the Heroku app. The second one contains the same key as the config/newrelic.yml file.
  • The heroku newrelic:stark addon is added to the heroku app

Solution

  • As per comments, check to make sure you config/newrelic.yml file is monitoring a production application.

    Set all newrelic keys only on heroku, not on local app. You only need a reference to: NEW_RELIC_LICENSE_KEY in all places. That constant should have nothing to read locally, and only read the heroku configs in production.

    Replace any local license keys with license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>' and turn development monitor_mode to false and production monitor_mode to true.

    All: read comments above for further details if this is unclear.