Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Adds Newrelic RPMs metrics to your dashboard.


Add the following gems to your Gemfile:

gem 'activeresource'
gem 'newrelic_api'

Update your bundle:


Put the newrelic_rpm.rb to jobs/newrelic_rpm.rb and configure your API key and Application name.

Finally, choose a metric (see "Emitted metrics" jobs/newrelic_rpm.rb) you want to show on the dashboard and add corresponding HTML code. For example, the code below shows Newrelic Throughput (requests/minute) on the scale of 100. Adjust the scale based on your application usage.

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="rpm_throughput" data-view="Meter" data-title="RPM" data-min="0" data-max="100"></div>
require 'newrelic_api'
# Newrelic API key
# Monitored application
# Emitted metrics:
# - rpm_apdex
# - rpm_error_rate
# - rpm_throughput
# - rpm_errors
# - rpm_response_time
# - rpm_db
# - rpm_cpu
# - rpm_memory
NewRelicApi.api_key = key
SCHEDULER.every '10s', :first_in => 0 do |job|
app = NewRelicApi::Account.find(:first).applications(:params =>
{:conditions => {:name => app_name}}
app.threshold_values.each do |v|
send_event("rpm_" + /, '_'), { value: v.metric_value })
Copy link

hannesfostie commented May 3, 2013

I've been looking into this in order to modify it to accept multiple accounts/applications/api keys and I ran into a problem where line 22..24 in your job file didn't actually return the correct application.

Given 2 applications on one account, with very distinct names, running your 'query' with the conditions it always returns both applications, so the first is always the same (given an alphabetical order). Where did you find this code? It doesn't appear to be mentioned on the NewRelicApi github page.

Copy link

morphizer commented Jul 31, 2013

I couldn't get the gem to return the application correctly, was quicker to parse the xml with nokogiri.

xml = Nokogiri::XML(open(
  '' + account_id + '/applications/' + app_id + '/threshold_values.xml',
  'x-api-key' => key

send_event('rpm_throughput', { value: xml.at_css('threshold_value[name="Throughput"]')['metric_value'] })

Copy link

erikwennerberg commented Oct 7, 2013

I wrote a gist that enables several New Relic applications in Dashing:

Copy link

bayleedev commented Oct 29, 2014

@morphizer here is the updated version

NewRelicApi.api_key = key

SCHEDULER.every '10s', :first_in => 0 do |job|
  app = { |el| == app_name

  app.threshold_values.each do |v|
    send_event("rpm_" + /, '_'), { value: v.metric_value })

Copy link

munish1 commented Mar 23, 2018

I know very old, wanted to add a data point. New Relic has deprecated the gem and is no longer work with new API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment