New Relic is a website performance monitoring service that can enable you to determine where bottlenecks exist in your Cloud Platform application. After sufficient traffic is requested from that environment, New Relic will begin to analyze the available data.
If you have a multisite configuration, you can also have New Relic report data on a per-website basis, which requires that each website have its own unique New Relic App name. (New Relic’s PHP API contains a call for setting your app name.) This data is available only for the environment as a whole, and you view it by selecting the appropriate sitename.env
option from the list of available applications (for example, mysite.prod
.)
Procedure
For each Drupal website that you want to monitor with New Relic, complete the following steps, depending on if you are using Cloud Platform or Site Factory:
Cloud Platform
Add the following code to the end of the website’s
settings.php
file:
if (extension_loaded('newrelic')) {
$exploded_path = explode('/', dirname(__FILE__));
$site_domain = array_pop($exploded_path);
newrelic_set_appname("$site_domain;CURRENT_APP_NAME", '', 'true');
}
Site Factory
For a
post-settings.php
hook script to use with your websites, see Altering values in settings.php with hooks.
Code variable descriptions
The $site_domain
variable is assigned the name of the folder for this particular settings.php
file. This appears in your list of applications on New Relic’s website. To find this list, go to New Relic.
The newrelic_set_appname()
function uses the following three parameters:
- APP_NAME(s) - New Relic allows each trace to be reported to up to three app names, but only one is necessary. Multiple app names make it possible to have New Relic both monitor the individual websites, but still keep monitoring the multisite as a whole to get an overview of how the entire application is performing.In the preceding code, replace
CURRENT_APP_NAME
with whatever the New Relic App name currently is. You can find this in New Relic under Settings > Environment > Agent initialization. Look fornewrelic.appname
. It needs to be exactly the same, or New Relic will create a new application and the trace history will be broken.The app name displayed in New Relic can be different from the actual New Relic app name, since it is possible to manually change the displayed name in the New Relic interface. - The New Relic subscription key - Leave this value blank to use the global key.
- The xmit identifier - If set to
true
, New Relic will keep the trace collected so far. This has a slight performance impact.
For additional documentation regarding New Relic, see their documentation website.