Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing New Relic without adding license key to repo

I want to install New Relic on one of my open source rails applications (v 3.2.12). I don't want to have the license key in the repo. I'd like to load it with something like ENV.

By default that's loaded in the newrelic.yml file.

Where is that YAML file loaded? I guess I could manually merge it with a hash that loads the license from the ENV hash.

Any hints on how to do that?

like image 460
Cyrus Avatar asked Feb 13 '13 22:02

Cyrus


People also ask

What should I do before installing new relic in Linux?

Before installing infrastructure, be sure to: Review the requirements. Have a valid New Relic license key. To install infrastructure in Linux, follow these instructions: Create the configuration file and add your license key:

What is a license key in New Relic?

The license key is a 40-character hexadecimal string associated with a New Relic account. When you first sign upfor New Relic, an organization with a single account and its own license key are created. If more accounts are added, each account starts with its own license key.

Do I need a New Relic account to install the agent?

Either way, you'll need a New Relic account if you don't have one. (It's free, forever.) Get an account Guided install EU guided install Step-by-step instructions If guided install doesn't work, you can install the agent manually.

Should I install new relic as root or privileged mode?

You should install the newrelic-infra package as root, privileged mode, or unprivileged mode if you don’t want to share the user’s identity. How Do I Install New Relic Agent On Windows?


1 Answers

I use the Figaro gem to handle secret keys with ENV environment variables, similar to you. For New Relic, I have:

config/application.yml (.gitignored and not pushed to source control)

# ...
NEW_RELIC_LICENSE_KEY: {{MY_KEY}}

which is then referenced in config/newrelic.yml:

# ...
license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>

A file called config/application.example.yml gets pushed up to the source code repo with instructions to put your own license key in:

config/application.example.yml

# ...
NEW_RELIC_LICENSE_KEY: # put your license key here

Also see this StackOverflow Q&A for more details:
What should be removed from public source control in Ruby on Rails?

like image 115
Paul Fioravanti Avatar answered Sep 29 '22 12:09

Paul Fioravanti