New Relic
Pivotal Web Services End of Availability Announced
For more information, see Frequently Asked Questions.
Page last updated:
Managing Services
To create and bind a service instance from the command line, see Managing Service Instances with the CLI.
Creating a Service Instance
An instance of this service can be provisioned via the CLI with the following command:
$ cf create-service newrelic lite INSTANCE
Replace INSTANCE
with a name that is meaningful to you.
Binding Your Service Instance
Bind the service instance to your app with the following command:
$ cf bind-service APP INSTANCE
Replace APP
with the app that you are binding and INSTANCE
with the name
that you gave your service instance.
Single Sign On
Follow the steps below to log into your New Relic Account via SSO:
Log into the Apps Manager.
Find your New Relic service instance on the Space page in which you created it.
Click Manage to log into the New Relic account for your instance via SSO.
Important Notes
To opt out of marketing emails from New Relic, log into the New Relic dashboard via SSO as described above and click the account drop-down in the top-right. In User Preferences, de-select I want to receive information emails, then click Save email preferences.
On the User Preferences page of the New Relic site is a field to change the email address for the account. Do not change the information in this field. Changing this information breaks SSO integration and prevents you from logging in to your account.
Sample Applications
Java
This sample Java app takes advantage of the Java buildpack’s zero-touch New Relic support. Create a NewRelic service instance on your Apps Manager dashboard. Use the included manifest.yml
to indicate which services you want bound to your application. All you need to do is clone, create the service instance, build, and push!
$ git clone -b newrelic https://github.com/cloudfoundry-samples/spring-music.git $ cd spring-music $ ./gradlew assemble $ cf push
Using New Relic with your Application
In order for metrics for your application to be reported to New Relic, the following three requirements must be satisfied:
- A New Relic agent bundled with your application
- A configuration file the agent requires
- An account-specific license key configured in the configuration file
All three of these things can be found by logging into your New Relic account as described above, but we want to make it even easier than that. See our language-specific solutions below.
Ruby / Rails
Add the New Relic agent gem to your Gemfile.
gem 'newrelic_rpm'
Rebuild the bundle if you want to test locally, but this isn’t required because Cloud Foundry will bundle the gem when you push your app.
$ bundle install
Add a New Relic configuration file to your project. This file needs to be configured with your license key and application name, but we’ve modified New Relic’s config file for Ruby to automatically read your application name and license key from environment variables which are set when the app is pushed. Download our modified newrelic.yml here and save it to
config/newrelic.yml
.$ wget -O config/newrelic.yml http://docs.run.pivotal.io/marketplace/services/newrelic/newrelic-ruby.yml
All you have left to do is push your app! If you don’t already have a New Relic service instance in your space, choose to create one when prompted. If you already have a New Relic service instance in your space, choose to bind to an existing service when prompted.
$ cf push
Now generate some usage on your app and log into New Relic via SSO as described above; you should see data coming through!
Java
- Build your app.
- Push your app to Cloud Foundry. If you don’t already have a New Relic service instance in your space, choose to create one when prompted. If you already have a New Relic service instance in your space, choose to bind to an existing service when prompted.
$ cf push
- Now generate some usage on your app and log into New Relic via SSO as described above; you should see data coming through!
Note: To specify the app name that New Relic uses, configure JAVA_OPTS
with -Dnewrelic.config.app_name=YOUR-APP-NAME
. Replace YOUR-APP-NAME
with the desired app name.
PHP
- Push the app:
$ cf push
- Create a New Relic service instance.
- Bind the service instance to the app instance.
- Re-stage the app:
$ cf restage app
- Go to the app URI and generate some usage data.
- Go to console.run.pivotal.io, choose Manage under your New Relic service, and connect to your app data.
Note: To specify the application name which New Relic uses, add a .user.ini
file to your app. For instance, to have your application
show in New Relic with two names, “Virtual Host 1” and “All Virtual
Hosts”, you can set the following in .user.ini
: newrelic.appname="Virtual Host 1;All Virtual Hosts"
.
Using an Existing New Relic License Key
If you have an existing New Relic license key instead of one provided by the Services Marketplace, refer to the language-specific instructions below:
Ruby
Run the following command to set the
NEWRELIC_LICENSE
environment variable to your license key:cf set-env YOUR-APP-NAME NEWRELIC_LICENSE LICENSE-KEY
Edit the
newrelic-ruby.yml
file obtained earlier as shown below. The following change allows thelicense_key
key to find your license key from the environment:license_key: ''
Java
From the cf CLI run
cf cups
to create a user-provided New Relic service instance:cf cups newrelic_INSTANCE_NAME -p "{\"licenseKey\":\"LICENSE-KEY\"}"
- Ensure that your New Relic instance name includes
newrelic
. This enables the New Relic Agent Framework to automatically configure the New Relic application to work with the service. - You can also include a display name for the instance in the New Relic interface by including
\"app_name\":\"PCF-APP-NAME\"
in the JSON structure string. - See User-Provided Service Instances for more information about the
cf cups
command.
- Ensure that your New Relic instance name includes
Bind the service instance to any app that you want to use it.
Re-stage the app:
$ cf restage YOUR-APP
PHP
Run the following command to set the NEWRELIC_LICENSE
environment variable to your license key:
cf set-env YOUR-APP-NAME NEWRELIC_LICENSE LICENSE-KEY
VCAP_SERVICES
When you bind your New Relic service instance with your application, Cloud Foundry makes a request to New Relic for the license key for your account. When you restart your application, we write this key to the VCAP_SERVICES
environment variable.
Format of VCAP_SERVICES
environment variable:
{
"newrelic-n/a":[
{
"name":"newrelic-14e9d",
"label":"newrelic-n/a",
"plan":"standard",
"credentials":
{
"licenseKey":"EXAMPLEaaaaf813af7989fccb24a699cb22a4beb"
}
}
]
}
For more information, see VCAP_SERVICES Environment Variable.
Support
Contacting Service Providers for Support
Documentation: https://newrelic.com/docs