• EnglishEspañol日本語한국어Português
  • EntrarComeçar agora

Migrate to NRQL

List metric names for your app

To view the metric names available for your application:

SELECT uniques(metricTimesliceName) FROM Metric WHERE appId = '$APP_ID' AND newrelic.timeslice.value IS NOT NULL SINCE 30 MINUTES AGO LIMIT MAX

You can also filter using the application name:

SELECT uniques(metricTimesliceName) FROM Metric WHERE appName = '$APP_NAME' AND newrelic.timeslice.value IS NOT NULL SINCE 30 MINUTES AGO LIMIT MAX

Or using a specific agent (host):

SELECT uniques(metricTimesliceName) FROM Metric WHERE realAgentId = '$AGENT_ID' AND newrelic.timeslice.value IS NOT NULL SINCE 30 MINUTES AGO LIMIT MAX

Get your app's metric timeslice data values

The REST API v2 accepts a list of metric names and a list of values to fetch metric timeslice data.

The metric names are the same, you can filter them with the metricTimesliceName field in your NRQL query.

Each API value can be mapped to a NRQL function, you can refer to the table below.

Example, for the following API request:

bash
$
curl -X GET "https://api.newrelic.com/v2/applications/${APP_ID}/metrics/data.json" \
>
-H "X-Api-Key:${API_KEY}" -i \
>
-d 'names[]=HttpDispatcher&values[]=average_call_time&values[]=call_count'

You would use the following query:

SELECT COUNT(newrelic.timeslice.value) AS call_count, average(newrelic.timeslice.value) * 1000 AS average_call_time
FROM Metric
WHERE appId = $APP_ID AND metricTimesliceName = 'HttpDispatcher'
Value (RPM)NRQL Function
average_response_timeaverage(newrelic.timeslice.value) * 1000
calls_per_minuterate(count(newrelic.timeslice.value), 1 minute)
call_countcount(newrelic.timeslice.value)
min_response_timemin(newrelic.timeslice.value) * 1000
max_response_timemax(newrelic.timeslice.value) * 1000
average_exclusive_timeaverage(newrelic.timeslice.value['totalExclusive'] / newrelic.timeslice.value['count']) * 1000
average_valueaverage(newrelic.timeslice.value)
total_call_time_per_minuterate(sum(newrelic.timeslice.value), 1 minute)
requests_per_minuterate(count(newrelic.timeslice.value), 1 minute)
standard_deviationstddev(newrelic.timeslice.value) * 1000
average_timeaverage(newrelic.timeslice.value) * 1000
countcount(newrelic.timeslice.value)
used_bytes_by_hostaverage(newrelic.timeslice.value) * 1024 * 1024
used_mb_by_hostaverage(newrelic.timeslice.value)
total_used_mbsum(newrelic.timeslice.value)
average_call_timeaverage(newrelic.timeslice.value) * 1000
total_valuesum(newrelic.timeslice.value)
min_valuemin(newrelic.timeslice.value)
max_valuemax(newrelic.timeslice.value)
raterate(sum(newrelic.timeslice.value), 1 second)
throughputrate(count(newrelic.timeslice.value), 1 second)
as_percentageaverage(newrelic.timeslice.value) * 100
errors_per_minuterate(count(newrelic.timeslice.value), 1 minute)
error_countcount(newrelic.timeslice.value)
total_timesum(newrelic.timeslice.value) * 1000
sessions_activeaverage(newrelic.timeslice.value)
total_visitssum(newrelic.timeslice.value)
percentaverage(newrelic.timeslice.value) * 100
percent (CPU/User Time)100 * sum(newrelic.timeslice.value) / $TIME_WINDOW_IN_SECONDS
time_percentage100 * sum(newrelic.timeslice.value) / $TIME_WINDOW_IN_SECONDS
utilization100 * sum(newrelic.timeslice.value) / $TIME_WINDOW_IN_SECONDS
visits_percentage100 * sum(newrelic.timeslice.value) / $TIME_WINDOW_IN_SECONDS

If the function includes $TIME_WINDOW_IN_SECONDS, it means that you need to replace it with the time window you want to query.

Example, if you query a 30 minutes time window, you would replace $TIME_WINDOW_IN_SECONDS with 1800.

Apdex metrics

Value (RPM)NRQL Function
scoreapdex(newrelic.timeslice.value)
sapdex(newrelic.timeslice.value) or count(newrelic.timeslice.value)
tapdex(newrelic.timeslice.value) or sum(newrelic.timeslice.value)
fapdex(newrelic.timeslice.value) or sum(newrelic.timeslice.value['totalExclusive'])
countapdex(newrelic.timeslice.value)
valueapdex(newrelic.timeslice.value)
thresholdmax(newrelic.timeslice.value)
threshold_minmin(newrelic.timeslice.value)

EndUser & Mobile metrics

These metrics will return the same result as what you would get from the REST API v2, but some results may differ from what you see on the New Relic UI. This is because the UI uses events instead of timeslice data. If you want to get the same results as the UI, you should query the events directly.

Value (RPM)NRQL Function
average_response_timesum(newrelic.timeslice.value) / count(newrelic.timeslice.value) * 1000
error_percentage(filter(count(newrelic.timeslice.value), WHERE metricTimesliceName = 'EndUser/errors') / filter(count(newrelic.timeslice.value), WHERE metricTimesliceName = 'Browser'))
average_fe_response_timesum(newrelic.timeslice.value['totalExclusive']) / count(newrelic.timeslice.value) * 1000
average_be_response_time1000 * (sum(newrelic.timeslice.value) - sum(newrelic.timeslice.value['totalExclusive'])) / count(newrelic.timeslice.value)
average_network_time(sum(newrelic.timeslice.value) - sum(newrelic.timeslice.value['totalExclusive']) - sum(newrelic.timeslice.value['sumOfSquares'])) / count(newrelic.timeslice.value)
total_network_time(sum(newrelic.timeslice.value) - sum(newrelic.timeslice.value['totalExclusive']) - sum(newrelic.timeslice.value['sumOfSquares']))
network_time_percentage(sum(newrelic.timeslice.value) - sum(newrelic.timeslice.value['totalExclusive']) - sum(newrelic.timeslice.value['sumOfSquares'])) / $TIME_WINDOW_IN_SECONDS
total_fe_timesum(newrelic.timeslice.value['totalExclusive'])
fe_time_percentage100 * sum(newrelic.timeslice.value['totalExclusive']) / $TIME_WINDOW_IN_SECONDS
average_dom_content_load_timeaverage(newrelic.timeslice.value) * 1000
average_queue_timeaverage(newrelic.timeslice.value['totalExclusive']) * 1000
total_queue_timesum(newrelic.timeslice.value['totalExclusive']) * 1000
total_dom_content_timesum(newrelic.timeslice.value) * 1000
total_app_timesum(newrelic.timeslice.value['sumOfSquares'])
average_app_timesum(newrelic.timeslice.value['sumOfSquares']) / count(newrelic.timeslice.value)
average_sent_bytessum(newrelic.timeslice.value['totalExclusive']) * 1000
average_received_bytes1000 * sum(newrelic.timeslice.value) / count(newrelic.timeslice.value)
launch_countcount(newrelic.timeslice.value)

Timeseries and summaries

By default, the REST API returns a series of metric data values based. To obtain the average of these values, you would include &summarize=true in your API call.

In NRQL, that's the opposite. You get a summary by default, and you can get the timeseries by adding TIMESERIES to your query.

Another difference is that the default time window of the REST API is 30 minutes, while in NRQL, it is 1 hour.

Query multiple metrics

You can still query multiple metrics at once with NRQL, here's an example:

SELECT
FILTER(1000 * AVERAGE(newrelic.timeslice.value), WHERE metricTimesliceName = 'HttpDispatcher') as average_response_time,
FILTER(count(newrelic.timeslice.value), WHERE metricTimesliceName = 'Errors/all') as error_count,
FILTER(average(newrelic.timeslice.value), WHERE metricTimesliceName = 'Memory/Heap/Max') as used_mb_by_host
FROM Metric
WHERE appName = '$APP_NAME'
SINCE 1 day ago
Copyright © 2024 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.