Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Targeting New Relic to run only on 1 (of 3) app servers

Our medium-sized rails app runs (in production) on three servers. We've just finished a trial period, using New Relic as a gem. During the trial period we tracked all three servers, but to continue with a subscription we only need (and only have the budget) to track app1.

So we need to disable new relic on app2 and app3. In communication with their customer service I'm told this is possible and have been directed to the last entry on this page but I can't quite figure out how this helps me to disable new relic tracking on the other two servers, in particular because there's no newrelic_rpm mentioned in environment.rb - it's a gem, after all, and is therefore only mentioned in the Gemfile.

There is a agent_enabled boolean option in newrelic.yml which I thought we could set on a per-server basis, but I don't know how to do this. Is there a way to find out which server we're on in rails, similar to the RAILS_ENV variable?

like image 952
omnikron Avatar asked Mar 14 '12 12:03

omnikron


2 Answers

The newrelic.yml file is rendered with ERB before the agent reads the config values. So you can do this:

monitor_mode: <%= 'app1' == Socket.gethostname ? 'true' : 'false' %>

That will enable the agent reporting to New Relic only for that one host.

like image 66
rkb Avatar answered Sep 24 '22 04:09

rkb


I would suggest linking newrelic.yml only on the server where it is needed. To make this happen remove config/newrelic.yml from you repository completely and put in into the shared directory in your servers instead.

Then link this file only for a certain role in capistrano again into config/newrelic.yml. You may introduce a new role that only contains your app1 server.

The new relic gem is build fail-safe. So it's just disabled in that case.

like image 24
iltempo Avatar answered Sep 22 '22 04:09

iltempo