Here are some examples of how to use the New Relic REST API (v2) to get Apdex data for your application and browser, for a specific application ID and API key. By default, this will provide a list of values every minute for the last 30 minutes in JSON format.
When acquiring data, the values returned may be affected by the time period you specify and the way the data is stored. For more information, see Extracting metric data.
Metric names and values for Apdex
To specify Apdex metric names and values with REST API calls, use these codes as needed.
Metric name | Metric value |
---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
The calculation used to determine the score
is explained in Apdex: Measuring user satisfaction. The following sections describe how to obtain the score
and the s, t, and f values used to arrive at it.
Average Apdex score
To obtain the average Apdex score
(both app and browser) for a specific time period, use this command. This example shows 24 hours in XML format for your application ID and its corresponding API key.
$curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.xml" \> -H "X-Api-Key:${API_KEY}" -i \> -d 'names[]=Apdex&names[]=EndUser/Apdex&values[]=score&from=2014-01-01T00:00:00+00:00&to=2014-01-02T00:00:00+00:00&summarize=true'
This will return the same Apdex scores shown in your APM Overview page.
Average Apdex metric values
To obtain the average Apdex metric values for a specific time range, use this command. This example shows 12 hours in XML format for your application ID and its corresponding API key.
$curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.xml" \> -H "X-Api-Key:${API_KEY}" -i \> -d 'names[]=Apdex&names[]=EndUser/Apdex&values[]=score&from=2014-06-09T00:00:00+00:00&to=2014-06-09T12:00:00+00:00&summarize=true'
Tip: To return a series of Apdex scores instead of an average, omit &summarize=true
.
All average Apdex values
To obtain the complete set of average scores, s
, t
, f
, count
, and threshold values for a specific time range, use this command. This example shows 24 hours (adjusted to the time zone 6 hours west of UTC by using %2B06:00
) in XML format for your application ID and its corresponding API key.
$curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.xml" \> -H "X-Api-Key:${API_KEY}" -i \> -d 'names[]=Apdex&names[]=EndUser/Apdex&from=2014-06-09T00:00:00%2B06:00&to=2014-06-10T00:00:00%2B06:00&summarize=true'
Dica
Even though this example adjusts the time zone, the output still returns as UTC time.