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.
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. Other customers may have multiple New Relic accounts at different subscription levels, and they need to control which host connects to which accounts. In both of these situations, you can use environment-specific settings.
Default settings for common environments appear at the bottom of the configuration file. Here is an example for production and staging:
New Relic .yml file example: This shows the default settings for production and staging environments.
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 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.
The New Relic agent determines the environment where it is running. For example, Ruby uses the standard
*RAILS_ENV OS environment variable.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.