Skip to content

Instantly share code, notes, and snippets.

@assimovt
Last active June 8, 2018 22:12
Show Gist options
  • Select an option

  • Save assimovt/5181244 to your computer and use it in GitHub Desktop.

Select an option

Save assimovt/5181244 to your computer and use it in GitHub Desktop.

Revisions

  1. Tair Assimov revised this gist Mar 17, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -14,4 +14,4 @@ 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 Throughtput (requests/minute) on the scale of 100. Adjust the scale based on your application usage.
    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.
  2. Tair Assimov created this gist Mar 17, 2013.
    17 changes: 17 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    # Setup

    Add the following gems to your `Gemfile`:

    gem 'activeresource'
    gem 'newrelic_api'


    Update your bundle:

    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 Throughtput (requests/minute) on the scale of 100. Adjust the scale based on your application usage.
    3 changes: 3 additions & 0 deletions newrelic_rpm.erb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    <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>
    </li>
    30 changes: 30 additions & 0 deletions newrelic_rpm.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    require 'newrelic_api'

    # Newrelic API key
    key = 'ENTER YOUR KEY'

    # Monitored application
    app_name = 'ENTER YOUR APPLICATION NAME'

    # 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}}
    ).first

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

    end