How do I control which hosts connect to my account?

Controlling which hosts connect to your account can easily be done by utilizing environment specific settings in the RPM 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 support article “How Do I Configure the Agent?”

Many RPM customers use a common configuration across multiple environments (i.e., staging and production), but may only run RPM on hosts in one of those environments.  Or depending on their needs, some customers may have multiple RPM accounts at different subscription levels, and need to control which host connect to which accounts. Both of these situations can easily be handled with environment specific settings.

You'll find default settings for common environments at the bottom of the newrelic.yml file such as the following for production and staging:

xterm.jpeg

These settings can be edited to suit your needs and custom environment sections can even be added for unique situations.  Wondering what those funky characters mean?  YAML provides node references ( * ) and hash merges (<<) that refer to a node labeled with an anchor (&) tag. More information about YAML is available here. 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 its running in:

For Ruby, the RPM agent determines the environment its running in from the standard ‘RAILS_ENV’ OS environment variable.

For Java, the RPM agent determines the environment its running in from a ‘JAVA_ENV’ OS environment variable, or from the following system property on the command line:

-Dnewrelic.environment=development

If neither are specified the default environment is 'production'