Apr 7

Using the New Relic API with Geckoboard

We’ve been using a great service called New Relic for monitoring our Rails applications for over 3 years, and recently, we’ve started to play around with the New Relic API. In particular, we’ve recently integrated New Relic stats into our monitoring dashboard (which we set up using Geckoboard).  Here are some more details about how we did this.

As discussed in a previous blog post, our Ruby library RestGraph (which was designed for the Facebook API) can be used for any arbitrary API.  This sample code shows how we use RestGraph to query New Relic to obtain the high level stats as a hash, e.g.:

{"Apdex"=>"0.85 [0.5]", "Error Rate"=>"0.33%",
"Throughput"=>"202 rpm", "CPU"=>"11%", "Response Time"=>"330 ms",     
"Errors"=>"0.67 epm", "Memory"=>"135 MB", "DB"=>"4.3%"}

To display the numbers on Geckoboard, we need to make the data available for polling by Geckoboard, which we do in the following file examples: geckoboard_controller.rb and newrelic.erb

Then we need to configure Geckoboard to poll this data and display it as a custom widget (in this example, we use the “RAG numbers only” widget, where RAG = red-amber-green).  The configuration can be seen here:

The final result is shown here on our Geckoboard, in the upper left corner:

In the next post, I’ll discuss another cool use of the New Relic API: we’re now using New Relic data to control the number of front-end server units (“dynos”) for our applications hosted on Heroku!

____

 John