Adding some sort of monitoring to your website is a good thing, New Relic has a pretty decent offering on their platform. In this post I will walk through how I setup New Relic to monitor this site.
First we have to understand what we want to monitor, then instrument it, then look at the fancy charts or add alerts.
I will be setting up the following New Relic products:
This will give server metrics like CPU usage and network usage from the host OS
This will give backend metrics like service memory usage and transactions from the NodeJS application service
This will give browser page load times, and other fancy things like where the readers are coming from.
The best way to get the Infrastructure agent up and running is to use the "Guided Install" method.
Clicking on the Guided Install button from the linked article will automagically open in New Relic your account if you are logged in.
Select your operating system, then a nifty little pre-populated command will pop up for you to copy into the terminal of your server.
curl -Ls https://raw.githubusercontent.com/newrelic/newrelic-cli/master/scripts/install.sh | bash && sudo NEW_RELIC_API_KEY=API_KEY NEW_RELIC_ACCOUNT_ID=ACCOUNT_ID /usr/local/bin/newrelic install
Just follow the prompts and give it the info requested. Since Ghost uses a MySQL backend database you may as well give the agent access to it when it requests it. You will then be able to see operations per second and queries per second in the third party integrations.
It will also detect an Nginx install and give you an opportunity to set that up. I needed to add a valid status URL as I usually remove the defaults from a Nginx install.
In case you run into issues, you can look here for tips [That is how I figured out the status URL issue]:
Once installed you should be getting some nice metrics and a few default dashboards.
Now for the fun part. The APM agent is installed via NPM and then required before the startup of Ghost.
Change to the directory where you have Ghost installed
Install the New Relic APM agent
npm install newrelic
That gets installed in the
node_modules directory, so we need to copy it out to the directory where you have your blog setup.
cp node_modules/newrelic/newrelic.js BLOG_DIRECTORY
We then edit the
newrelic.js file with our app name, and New Relic license key.
Next, we edit the
index.js file in the
We add the following to the first line in the file:
var newrelic = require('newrelic');
Finally, we restart the Ghost blog and start sending traffic to it once it is back online.
After a few minutes you will hopefully see some web transactions
The New Relic docs explain better:
Once your blog has been online for awhile you can see how it performs and then setup appropriate alerting and notifications.
I hope this is helpful and kickstarts your Ghost blog monitoring journey.