Skip to content

Instantly share code, notes, and snippets.

What would you like to do?


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. Specify your app IDs (found in the New Relic URL of an application), and define the corresponding metrics in the .erb.

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="YOURAPPID1_rpm_throughput" data-view="Meter" data-title="RPM" data-min="0" data-max="100"></div>
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="YOURAPPID2_rpm_throughput" data-view="Meter" data-title="RPM" data-min="0" data-max="100"></div>
require 'newrelic_api'
# Newrelic API key
# Monitored application
app_id = ['YOURAPPID1' ,'YOURAPPID2']
# 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|
newrelicapp = NewRelicApi::Account.find(:first){|app| == app_id }.first
newrelicapp.threshold_values.each do |v|
puts v.metric_value
send_event( + "_rpm_" + /, '_'), { value: v.metric_value })
Copy link

nicovs commented Nov 1, 2013

Hi Erik,

I get this error when using your NR dash:
scheduler caught exception:
undefined method threshold_values' for nil:NilClass /var/www/dashboard_publicdash1/jobs/newrelic_rpm.rb:26:inblock in <top (required)>'


Copy link

mjc commented Dec 7, 2013

My fork contains a fix for that error as well as a bit of a refactor: newrelic_rpm.

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