Newrelic plugin


(Sam Saffron) #1

New Relic support

Author: Sam Saffron

Support for http://newrelic.com

plugins/newrelic/plugin.rb

# name: enable New Relic rpm
# about: New Relic support
# version: 0.1
# authors: Sam Saffron

ENV["NRCONFIG"] = File.expand_path('../newrelic.yml', __FILE__)
gem "newrelic_rpm", "3.6.7.152"

NewRelic::Control.instance.init_plugin :config => Rails.configuration

after_initialize do
  ForumsController.newrelic_ignore :only => [:status]
end

plugins/newrelic/newrelic.yml

The file you got from newrelic

TODO: move this to git


Monitor: Best solutions for keeping track of uptime?
Specify external gem dependencies for plugins
How to configure Discourse Docker on higher end servers
Specifying the gem dependecies for plugin - gem does not exist
Site monitoring service/software
(Allen - Watchman Monitoring) #2

For the documentation:

Installation

Copy this file into
plugins/newrelic/plugin.rb

Retrieve a copy of your newrelic.yml file:

https://rpm.newrelic.com/accounts/[123456]/newrelic.yml

Where you need to replace 123456 with the application number you see in your NewRelic interface.

Save this to config/newrelic.yml`

(unless there’s some reason to keep it at the root of the install, as shown above)

Otherwise I’d change that 6th line to:
../config/newrelic.yml

Activation

The Newrelic gem will be installed the next time bundler is called.

cd /var/www/discourse (or or where you’ve installed discourse)
bundle install --without test --deployment

(is that correct?)


(Allen - Watchman Monitoring) #3

Would I need to do anything else besides what’s outlined?

Is that bundle command needed?


(Patrick) #4

New Relic is wicked. Thanks for the plugin!


(David Celis) #5

I took it upon myself to create a GitHub repository for this; it’s pretty much unchanged, but it does use the most up-to-date Ruby agent version while also providing a newrelic.yml file that will look for NEW_RELIC_LICENSE_KEY and NEW_RELIC_APP_NAME variables.

Bonus: installation instructions for the Docker image. Thanks for the initial version, @sam!


(Cooper Marcus) #6

Nice!

@davidcelis would you mind if we added this to Connect APM Data with Your Apps | New Relic Partners ?


(David Celis) #7

Yep, we should do that.


(Hunter Owens) #8

@davidcelis

Is there anyway to use your github version without restarting and loosing the content of an initial app with a container?


(David Celis) #9

You won’t lose the content, as both the PostgreSQL and Redis databases are stored in a folder that’s shared with the host. You will have to destroy the container and re-bootstrap it, but all your data (posts, users, topics, etc.) will still be there.

I wish there was a better way.


(Evaryont 🎆) #10

For anyone else looking to further integrate New Relic, they offer an availability monitoring service. This way you can get alerts if Discourse ever goes down. (Ideally, that would be never!)

Discourse already has an OK status URL that works wonderfully for this purpose. If you go to your Discourse application in New Relic, then Settings -> Availability Monitoring, New Relic asks for a URL to monitor. You can use /srv/status from your application, like https://meta.discourse.org/srv/status and hit “Save”.