Module: NewRelicApi

Defined in:
lib/new_relic_api.rb

Overview

New Relic REST API

This is a helper module for working with the New Relic API’s XML interface. Requires Rails 2.0 or later to be loaded.

Can also be used as a script using script/runner.

In this version of the api, authentication is handled using your account API key, available in your Account settings in rpm.newrelic.com.

Log in, click Account at the top of the page and check the “Make my account data accessible” checkbox. An API key will appear.

Refer to the README file for details and examples on the REST API.

Examples

# Fetching the list of applications for an account
NewRelicApi::Account.find(:first).applications

# Fetching the health values for all account applications
NewRelicApi::Account.application_health

# Fetching the health values for an application
NewRelicApi::Account.find(:first).applications.first.threshold_values

# Finding an application by name
NewRelicApi::Account.find(:first).applications(:params => {:conditions => {:name => 'My App'}})

Defined Under Namespace

Modules: AccountResource, AgentResource Classes: Account, Application, BaseResource, Deployment, Subscription, ThresholdValue, User

Constant Summary collapse

ACCOUNT_RESOURCE_PATH =

:nodoc:

'/accounts/:account_id/'
ACCOUNT_AGENT_RESOURCE_PATH =

:nodoc:

ACCOUNT_RESOURCE_PATH + 'agents/:agent_id/'
ACCOUNT_APPLICATION_RESOURCE_PATH =

:nodoc:

ACCOUNT_RESOURCE_PATH + 'applications/:application_id/'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyObject

Returns the value of attribute api_key.



34
35
36
# File 'lib/new_relic_api.rb', line 34

def api_key
  @api_key
end

.hostObject

Returns the value of attribute host.



34
35
36
# File 'lib/new_relic_api.rb', line 34

def host
  @host
end

.portObject

Returns the value of attribute port.



34
35
36
# File 'lib/new_relic_api.rb', line 34

def port
  @port
end

.sslObject

Returns the value of attribute ssl.



34
35
36
# File 'lib/new_relic_api.rb', line 34

def ssl
  @ssl
end

Class Method Details

.reset!Object

Resets the base path of all resources. This should be called when overridding the newrelic.yml settings using the ssl, host or port accessors.



38
39
40
41
# File 'lib/new_relic_api.rb', line 38

def reset!
  @classes.each {|klass| klass.reset!} if @classes
  NewRelicApi::Account.site_url
end

.track_resource(klass) ⇒ Object

:nodoc:



44
45
46
# File 'lib/new_relic_api.rb', line 44

def track_resource(klass) #:nodoc:
  (@classes ||= []) << klass
end