You can control which hosts connect to your account by using environment-specific settings in the New Relic agent configuration file, newrelic.yml. There are configuration properties that can be set for all of your environments, or modified for just an individual environment. For general information on the agent configuration parameters refer to the configuration documentation for your specific agent.
Many New Relic customers use a common configuration across multiple environments (for example, staging and production), but may only run New Relic on hosts in one of those environments. Or depending on their needs, some customers may have multiple New Relic accounts at different subscription levels, and need to control which host connect to which accounts. In both of these situations, you can use environment-specific settings.
Default settings for common environments are at the bottom of the newrelic.yml file, such as the following for production and staging:
You can edit these settings to suit your needs. You can also add custom environment sections for unique situations. YAML provides node references ( * ) and hash merges (<<) that refer to a node labeled with an anchor (&) tag. More information about YAML is available in Wikipedia. The default newrelic.yml 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 are allowed to connect to your account simply set the '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.
How the agent determines the environment it is running in:
For Ruby, the New Relic agent determines the environment it is running in from the standard ‘RAILS_ENV’ OS environment variable.
For Java, the New Relic agent determines the environment it is running in from a ‘JAVA_ENV’ OS environment variable, or from the following system property on the command line:
If neither are specified, the default environment is production.
If you still have problems, submit a support ticket (for fastest service) or email support @ New Relic. Also, you may be able to find support from the community at Stack Overflow. Tag your post with