New Relic – Beta

Using AppFirst’s Poll-aroid – New Relic plugin

The following is a walkthrough for using Poll-aroid to collect data from New Relic for inclusion into the AppFirst backend.

Finding Metrics in New Relic

First, Collect the following information from your New Relic Account:

  • API Key
  • Application ID
  • Metric Name

For the API Key, you must enable API Access in your New Relic account. You can do this by selecting Account settings from the menu on the top right of your New Relic account.

AF-NR Beta1

Then navigate to Integrations – Data sharing, where you can create an API key for API access:

AF-NR Beta2

Once you have the API key, you need to use New Relic’s API explorer to find the metrics you want to collect. The API explorer is at https://rpm.newrelic.com/api/explore/. Once you’ve selected your account from the top right, you should see the full API list on the left of the window:

AF-NR Beta3

If you don’t see the Metric Names and Metric Data listings, you either don’t have the account selected, or are using a Lite account, which doesn’t support API data.

If you select the Metric Names option, you will be presented with the parameters page:

AF-NR Beta4

This is the first place to build your API query. This requires the use of your API key previously generated, and the application_id of the application you want metrics from. You can retrieve this value from the URL in your application:

AF-NR Beta5

The application ID in this example is 3088471.

Once you’ve entered this data and send the request, the page will update with a JSON formatted response:

AF-NR Beta6

The name field is the Metric name we’ll be using with Poll-aroid to bring the data into the AppFirst data stream. Once collected, you can then integrate this data with Poll-aroid.

Using Poll-aroid

AppFirst’s Poll-aroid can be downloaded from our GitHub account at http://github.com/appfirst/poll-aroid. You can clone this directly onto the system conducting the polling.

AF-NR Beta7

We’ve provided some basic shell scripts to assist with the setup and execution of poll-aroid commands. For full command line options, running the AfPoller.py with -h (or –help), will provide a list of accepted options.

An example of collecting the Apdex score from New Relic:

AfPoller.py --plugin=newrelic --newrelic-access-key-id= --newrelic-access-app-id=3088471 -m Apdex -a Magento

This will query New Relic Application ID 3088471 and request the Apdex metric name. The -a option specifies the application name for our StatsD bucket. The New Relic API explorer returns the following for Apdex:

AF-NR Beta8

When the command is run, Poll-aroid will retrieve this data from New Relic’s API and feed it into the AppFirst data stream. The StatsD bucket will then contain the following:

Magento.Apdex.s
Magento.Apdex.t
Magento.Apdex.f
Magento.Apdex.count
Magento.Apdex.score
Magento.Apdex.value
Magento.Apdex.threshold
Magento.Apdex.threshold_min

After you’ve tested the command, we recommend using the check_newrelic.sh script to protect your API key. The last step is scheduling poll-aroid to run.

Running Poll-aroid

Any polled item, including nagios scripts or other custom developed scripts that you’d like to run on interval can be added to the polled data config page for the collector. To access this page, from the AppFirst web console, go to Administration – Collectors.

AF-NR Beta9

Then select edit for the system containing the Poll-aroid scripts.

AF-NR Beta10

The next window will contain a tab for Polled Data config.

AF-NR Beta11

In this window, at the bottom, add the following:

# Retrieve Apdex Score from New Relic
command[NR_Apdex]=/usr/share/appfirst/plugins/libexec/check_newrelic.sh

And save. Now, during the interval listed on the Collector Config page (default: 300 seconds), the check_newrelic.sh script will run and collect the Apdex score. You can then view this information in Correlate, or on the dashboard using the StatsD name.