Knowledge Base/Engine Yard Cloud Documentation/Add-ons

Monitor Applications with the New Relic Add-on

Keri Meredith
posted this on July 09, 2012 01:29 PM

Updated: October 30th, 2013

New Relic application performance management solutions enable developers and operations teams to quickly and cost effectively monitor, troubleshoot, and tune application performance in real time. You can view the health and availability of your production app so you can be sure it's tuned, optimized, and running at its peak. New Relic provides app visibility such as aggregate app response time and throughput.

The New Relic add-on can help you understand if your app or your server needs help by providing real-time application performance. Server utilization info from the app perspective includes CPU utilization; network bandwidth, packets/sec, errors/sec; and server configuration summaries. For more information, see New Relic best practices.

Your New Relic account is created using your Engine Yard account and password.

The New Relic Standard plan is free for Engine Yard accounts. As an incentive, all new accounts start with a free 14-day trial of the New Relic Professional plan. If you select the Professional plan, the New Relic charge appears on your Engine Yard Cloud account bill. You do not get a separate bill from New Relic.

Important: If you previously set up New Relic with the original integration (Account Settings page), you should not attempt to use the new add-on with the same account. For new accounts, use the New Relic add-on, as described below. If you would like to convert from the original integration to the new add-on, contact Engine Yard Support.

Prerequisites

Before you set up the New Relic add-on, ensure that you have met the prerequisites:

  • If you have a trial Engine Yard account, you must upgrade to a full account before you can set up an add-on.

  • Consider which applications and environments need New Relic monitoring, and which plan is right for you.

  • You should be ready to deploy your application.

  • You should be ready to upgrade your environment (if it has not been upgraded since November 13th, 2012).

New Relic with Ruby

The New Relic add-on process for your Ruby application requires the following main steps:

New Relic with PHP

The New Relic add-on process for your PHP application only requires one main steps:

Set up the New Relic add-on service

Important: If you previously set up New Relic with the original integration (Account Settings page), you should not attempt to use the new add-on with the same account. If you would like to convert from the original integration to the new add-on, contact Engine Yard Support.

To sign up and activate your apps for New Relic monitoring

  1. Log in to your account.

  2. Navigate to this URL: https://cloud.engineyard.com/addons/newrelic.

  3. Review the add-on details page to learn more about the New Relic service.

  4. Click the Set it up tab.
  5. Click addons_signup.png to accept the terms and conditions.

    This sets up your New Relic login and password with SSO (providing the same sign-on as Engine Yard Cloud).

  6. On the New Relic Set it up page, select the environment you want to extend with New Relic monitoring.

    NewRelic_Activate.png

  7. Click Activate_Button.png to enable the New Relic add-on service for the selected environment.

  8. Navigate to your Environment page and click "Apply" for the changes to take effect.

    FOR PHP APPLICATIONS ONLY: Scroll to the bottom of the Environment page to confirm that New Relic is listed as an add-on.

    add_on_complete_php.png

    For a PHP application, you are done. Your New Relic add-on process is complete. Wait a few minutes for data to start reporting to New Relic.

    Note: If you have multiple apps/environments, then multiple selections appear in the list. Select and click Activate for each app / environment that you want to extend with New Relic.

Deploy the New Relic add-on service

You need to update code before the New Relic add-on service becomes available:

  • Modify your Gemfile.
  • Set up config/newrelic.yml.

Note: If your framework environment is not staging or production, you must add it to newrelic.yml.

Follow the instructions below (from the Set it up page).

To update and deploy your apps for New Relic monitoring

  1. Modify your Gemfile by adding the following lines:

    gem 'ey_config' 
    gem 'newrelic_rpm'
    
  2. Add the Engine Yard newrelic.yml to your application repository.

    • Download the Engine Yard version of newrelic.yml.

    • Place the newrelic.yml file in the config subdirectory of your application.

  3. Push all changes to your git repository host (e.g., GitHub).

  4. Click on the environment link to go to your application environment in Engine Yard Cloud.

    NewRelic_GotoDeploy.png

  5. On the environment page, click deploy_button.png to deploy the code changes for the New Relic add-on service.

    This deploys the changes to the Gemfile and to the config/newrelic.yml file.

  6. Click upgrade_button.png to ensure you have the November 13th, 2012 or later Engine Yard stack update, which includes database server monitoring.

    This installs the required New Relic functionality.

Note: If you have multiple apps/environments, then you need to repeat the steps in this section for each environment you are extending with New Relic.

Note: Your New Relic add-on charges (if any) appear on your Engine Yard Cloud account bill. You do not get a separate bill from New Relic.

Verify New Relic configuration

After an environment has been configured and updated with the New Relic add-on, verify the set up.

To verify the New Relic add-on

  1. Log in to your account.

  2. Navigate to this URL: https://cloud.engineyard.com/addons/newrelic.

  3. Click  addons_newrelic_dashboard_link.png 

    The New Relic menu should look something like this:

    NewRelic_LeftMenu.png

  4. If you see this:

    NewRelic_SearchingForApp.png

    ... your app / environment is probably not yet deployed. See the Troubleshooting section below.

View New Relic performance data for your application

You can access your New Relic account directly from Engine Yard Cloud to view monitoring details about your application and its servers.

To view the New Relic add-on data

  1. Log in to your account.

  2. Navigate to this URL: https://cloud.engineyard.com/addons/newrelic.

  3. Click  addons_newrelic_dashboard_link.png 

    This links to the New Relic website where you can review your data.

    NewRelic_LeftMenu.png

    Tip: Bookmark this New Relic URL.

  4. To view your application metrics, click the Applications link.

    Note: An "application" in New Relic terms is equivalent to an environment in Engine Yard Cloud.

  5. To view your server metrics, click the Servers link.

    New Relic server metrics are available for single server, app, app master, database, and utility servers.

Use New Relic deploy notifications

New Relic can help you keep track of your application deploys.

To track application deploys

  1. Add the following deploy hook to your application:

    # deploy/after_restart.rb
    run "cd #{release_path} && bundle exec rake RAILS_ENV=#{environment} APP=#{app} DEPLOYED_BY=\"#{deployed_by}\" REVISION=#{revision.chomp} NR_KEY=#{node[:newrelic_key]} newrelic:notify"
    
  2. Add the following Rake task to your application:

    # lib/tasks/newrelic.rake
    namespace :newrelic do
      task :notify => :environment do
        require 'newrelic_rpm'
     
        if Rails.env.production? 
          # Notify New Relic of deployment
          puts "Log deployment of #{ENV['REVISION']} with NewRelic"
          app = ""
          key = ""
          if ENV['NR_KEY'].blank?
            app = Rails.application.class.parent_name
            key = EY::Config.get("New Relic", 'license_key')
          else
            app = ENV['APP']
            key = ENV['NR_KEY']
          end
          begin
            `curl -H "x-license-key:#{key}" -d "deployment[app_name]=#{app}" -d "deployment[revision]=#{ENV['REVISION']}" -d "deployment[user]=#{ENV['DEPLOYED_BY']}" https://rpm.newrelic.com/deployments.xml`
          rescue  Exception => e  
            puts "The following error occurred: #{e.message}"
          end
        end
      end
    end
    
  3. Click Deploy.

Transfer Account Ownership

If you want to transfer your New Relic account to a new owner, you can do so on the New Relic UI.

To transfer your account to a new owner:

  1. Navigate to your New Relic dashboard.
  2. Click Account Settings tab.
  3. Click Add User.
  4. Enter the new user information.
  5. Click Change Owner.

    new_relic_ui.png

If you encounter problems with your New Relic account, such as no application data being reported, submit a ticket with Engine Yard Support

Troubleshooting

SymptomSolution
When I view the New Relic dashboard, it looks like it's not set up yet. The Gemfile was modified and we set up config/newrelic.yml.         You must click Deploy to update the configuration for each environment that you are extending with New Relic.
Server monitoring is not working.             You need a Chef run to install the New Relic daemon that monitors server resources. Click Upgrade on each environment that you are extending with New Relic. (Fixed in July 24, 2012 stack upgrade.)
Server monitoring does not work (/etc/newrelic/nrsysmond.cfg and /data/*/current/config/newrelic.yml have different license keys). We strongly recommend against using the original New Relic integration (Account Settings page) as well as the new add-on, as this issue results. You also will have double billing and the new account will not reflect historical data. If you would like to convert from the original integration to the new add-on, contact Engine Yard Support.

If you are testing:

Running in development mode - this error appears: Error reading newrelic.yml file: Expected to find EY::Config YAML file at one of: ["config/ey_services_config_deploy.yml", "config/ey_services_config_local.yml"] (RuntimeError)

New Relic doesn't require a valid license key in development mode. The easiest thing to do is create config/ey_services_config_local.yml
'New Relic':
license_key: "NA"
When you deploy, this file remains, however a config/ey_services_config_deploy.yml file is also written; it contains your real license key and takes precedence.

If you have feedback or questions about this page, add a comment below. If you need help, submit a ticket with Engine Yard Support.

 

Comments

User photo
Ilya Scharrenbroich
Doormates

I see that the server is being monitored for my rails application, however, the application is not showing up.  These instructions are very confusing.

April 10, 2013 09:32 AM
User photo
Keri Meredith
Engine Yard Inc.
Hi Ilya, sorry you are having trouble. Please log a Support ticket so we can help you.

Also, I'd like to understand which parts of the doc you find confusing.

Thanks for your feedback! kjm
April 10, 2013 09:38 AM
User photo
Ilya Scharrenbroich
Doormates

Thanks, I just filed a ticket. There seems to be missing information on Application monitoring.

April 10, 2013 09:43 AM
User photo
Daniel Nelson
Populr

https://cloud.engineyard.com/addons/newrelic listed in the instructions above is not working for me. It keeps redirecting me to https://cloud.engineyard.com/accounts/11602/services

June 28, 2013 06:46 AM
User photo
Kevin French
Engine Yard Inc.

Daniel,

If you are logged into your Cloud account and seeing this issue, please open a ticket and we will be happy to assist. You can also reach out to me in Skype at kevinfrench-ey and I will happily assist. Thanks!

June 28, 2013 06:52 AM
User photo
Daniel Nelson
Populr

Thank you, Kevin. I've opened a ticket.

June 28, 2013 07:21 AM
User photo
Ches Martin
Admin500

The chef cookbook for using an existing New Relic account instead of one locked-in to Engine Yard's add-on system was removed recently:

https://github.com/engineyard/ey-cloud-recipes/commit/af9c25109576d...

Are you no longer supporting this arrangement at all in docs and an unsupported cookbook, or is there a new preferred way to achieve this?

July 04, 2013 04:19 AM
User photo
Evan Machnic
Engine Yard Inc.

Ches,

New Relic Server Monitoring is now set up by default when the Add-on is activated for an environment, therefore we have deprecated the cookbook in favor of using the Add-on. If customers wish to use a New Relic account outside of our integration then they will need to set things up manually.

Cheers,
Evan Machnic

July 04, 2013 08:05 AM
User photo
Ches Martin
Admin500

Gotcha, thanks Evan. I've resurrected the removed cookbook in our internal fork of the cookbooks repo so I'll stick with that approach.

July 05, 2013 02:56 AM
User photo
Sara Trice
Wowzers, Inc.

The deploy notification was failing because the app name I was passing was wrong. I had to change my deploy hook to:

# deploy/after_restart.rb
run("cd #{config.release_path} && bundle exec rake RAILS_ENV=#{config.framework_env} APP=\"#{config.environment_name} / #{config.app} (#{config.framework_env})\" DEPLOYED_BY=\"#{config.deployed_by}\" REVISION=#{config.revision.chomp} NR_KEY=#{node[:newrelic_key]} newrelic:notify")

 

Not sure if this was just me but figured I'd mention it in case it saves someone else some trouble.

September 21, 2013 11:19 AM
User photo
Laurent Fallet
tbcast

Is there any good reason for not putting the newrelic notification in after_deploy instead of after_restart ?

As maintenance page is removed after the after_restart phase, moving the newrelic notification in last position should reduce the app downtime. Am I missing something ?

November 05, 2013 09:07 AM
User photo
Emmet Murphy
dealbase-corp

When New Relic Server Monitoring is set up by activating the Add-on for an environment, is there a similarly simple way of installing additional plugins like memcached, MySQL, haproxy, etc? Or do we then need to resort to Chef cookbooks?

April 22, 2014 11:51 AM
User photo
Ralph Bankston
Engine Yard Inc.

Hi Emmet,

 

Currently the plugins require manual installation or custom chef to install.

April 22, 2014 01:40 PM
User photo
Tasha Drew
Engine Yard Inc.

Hi Emmet, 

We also have a bunch of add-ons with partners that do things like memcached as a service, mysql as a service, etc., if that's what you were thinking about.

April 22, 2014 01:42 PM
User photo
Emmet Murphy
dealbase-corp

Thanks and follow up question: Does the chef cookbook have access to EngineYard configuration such as the AWS access and secret keys, similar to the access in the Rails config like the following?

        key = EY::Config.get("New Relic", 'license_key')
April 22, 2014 04:12 PM