New Relic just added Node.js applications’ monitoring a few days and perfect timing too! With Ghost just being released, New Relic is the perfect tool to keep an eye on how your Ghost blog installation is performing. This tutorial assumes the obvious that you already have Node.js and Ghost running on your server.
To turn on monitoring, visit your New Relic account and in your ‘Applications’ panel and click on ‘Get Started’. Choose ‘Node.js’ for the agent you want to use.
Go in to the root of your Ghost installation on your server. My root folder is located at /home/site/public_html/ghost.
If you are on Ubuntu like me and logged on as root or an account which has root access, you can navigate to your root folder by typing in the following command -
sudo cd /home/site/public_html/ghost
Once in the folder, type this is to download and install the New Relic agent.
sudo npm install newrelic
This will download the agent and all related dependencies. Now we need to configure the agent to start sending data to New Relic servers. Copy the newrelic.js from the newrelic folder to the root folder of your Ghost folder.
sudo cp node_modules/newrelic.js /home/site/public_html/ghost/newrelic.js
Open up the newly copied file for editing.
sudo nano newrelic.js
Replace the default value for “app_name” with your own. This can be anything that will allow you to easily recognise the application on your New Relic dashboard. I put mine as “Ghost Blog”.
Next, replace the “license_key” value with your license key. You can find your license key from the same page from where you chose the monitor to install.
Save the file and open up index.js as the last step before you can see your blog showing up on your New Relic dashboard.
sudo nano /home/site/public_html/ghost/index.js
In the first line, write this line.
var newrelic = require('newrelic');
Save the file, restart Ghost and you are done!
You should start seeing your application data within 5 minutes on your New Relic dashboard if everything went well.
The only problem here is that you will have to add this line to the index.js file everytime you update your Ghost blog, atleast until someone makes a plugin to make this easier.
Cheers, and happy blogging! If you have any problems, leave your comments below.