You can control which hosts connect to your account by using environment-specific settings in the New Relic agent configuration file. You can set some configuration properties for all of your environments or modify them for an individual environment. For more information about the config file and where to find it, see the configuration documentation for your agent.
Default settings
Many New Relic customers use a common configuration across multiple environments (for example, staging and production), but they may only run New Relic on hosts in one of those environments. You can use environment-specific settings to isolate which hosts report to New Relic.
Default settings for common environments appear at the bottom of the configuration file. Here is an example for production and staging:
staging: <<: *default_settings app_name: <%= app_name %> (Staging)
production: <<: *default_settings
Customized settings
You can edit these settings as needed. You can also add custom environment sections for unique situations. For example, YAML provides node references ( *
) and hash merges (<<
) that refer to a node labeled with an anchor (&
) tag. The New Relic agent's default configuration file ships with common configuration options set to the &default_settings
tag, but you can create your own to share configuration options across environments.
To control which hosts may connect to your account, set monitor_mode
to true or false in the appropriate environment. To have your staging hosts connect to one account and your production hosts connect to another account, set the license_key
in each environment according to how you would like to have them connected. As you can see in the screenshot above, you can also set the app_name
and any other setting you may want specific to a given environment.
Environments
The New Relic agent determines the environment where it's running. For example, Ruby uses the standard RAILS_ENV
environment variable for Rails applications.