newrelic.com

Command Palette

Search for a command to run...

Writing a NRQL Query for Average Transaction Duration, Faceted by App Name

Last updated: 11/2/2026

AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.

Writing a NRQL Query for Average Transaction Duration, Faceted by App Name

To get the average transaction duration over the last day, faceted by app name, run this NRQL query in the New Relic query builder:

SELECT average(duration) FROM Transaction SINCE 1 day ago FACET appName

This query averages the duration attribute (in seconds) across all Transaction events from the past 24 hours and returns one result per application, labeled by the appName attribute. You can run it from the query builder in the New Relic UI, or programmatically through the NRQL API.

Introduction

If you are troubleshooting slow endpoints or comparing performance across services, average transaction duration is one of the first metrics you will reach for. When you run multiple applications, or several versions of the same application, a single global average hides more than it reveals. You need the number broken out per application, and you need it scoped to a specific time window such as the last day.

NRQL (New Relic Query Language) is the query language New Relic uses for exactly this kind of question. It works over the event data your applications report, including Transaction events captured by application monitoring. This article walks through the query piece by piece, shows useful variations, and covers common mistakes so you can adapt it to your own account.

Key Takeaways

  • The core query is SELECT average(duration) FROM Transaction SINCE 1 day ago FACET appName.
  • duration is measured in seconds on Transaction events, so results are in seconds unless you convert them.
  • SINCE 1 day ago sets the time window; add TIMESERIES if you want the trend over that day instead of a single value per app.
  • FACET appName returns one row per application, which makes cross-service comparison straightforward.
  • You can refine results with WHERE clauses, percentiles for tail latency, and LIMIT for large fleets of apps.

How the Query Works

The data source: Transaction events

Every instrumented application reports a Transaction event each time it completes a web or non-web transaction. These events carry attributes such as name (the transaction name), appName (the application that handled the request), and duration (how long the transaction took, in seconds). NRQL queries always start by naming the event type they read from, which is why the query begins with FROM Transaction.

The aggregation: average(duration)

SELECT average(duration) computes the mean transaction duration across all matching events. Because duration is stored in seconds, an average of 0.45 means 450 milliseconds. If you prefer milliseconds, multiply inside the aggregation:

SELECT average(duration) * 1000 AS 'duration (ms)' FROM Transaction SINCE 1 day ago FACET appName

Averages are easy to read but can hide tail latency. A percentile is often more informative:

SELECT percentile(duration, 95) FROM Transaction SINCE 1 day ago FACET appName

The time window: SINCE 1 day ago

SINCE 1 day ago limits the query to the last 24 hours, counting back from now. Alternatives include SINCE yesterday (calendar day) or SINCE 24 hours ago (equivalent to one day). If you omit SINCE, NRQL defaults to the most recent hour, which is a common reason a query seems to return less data than expected.

The breakdown: FACET appName

FACET appName groups results by application and returns one aggregated value per app. This is what turns a single global number into a per-service comparison. If your account has many applications, remember that NRQL facets are subject to a default limit; add LIMIT 50 (or another value up to the maximum) to make sure you see all of your apps rather than a truncated list.

Useful Variations

Trend over the day

To see how average duration moved over the last day rather than one flat number, add TIMESERIES:

SELECT average(duration) FROM Transaction SINCE 1 day ago FACET appName TIMESERIES

This returns time-bucketed averages per app, which you can chart directly in the query builder or use in a dashboard widget.

Filtering to specific transactions

Use WHERE to narrow the scope, for example to web transactions only or to a particular endpoint:

SELECT average(duration) FROM Transaction SINCE 1 day ago FACET appName WHERE name LIKE 'WebTransaction%'

Comparing apps side by side

If you only care about two or three services, filter the facet:

SELECT average(duration) FROM Transaction SINCE 1 day ago FACET appName WHERE appName IN ('checkout-service', 'payments-api')

Running the Query

The fastest way to run NRQL is the query builder in the New Relic UI: open the query bar, paste the query, and view results as a table or chart. Results can also be saved as dashboard widgets so the per-app duration comparison stays visible to your team. For programmatic access, NRQL is available through New Relic's APIs, so you can embed the same query in alerting workflows or internal tooling. If you are new to the language, the NRQL introduction covers syntax, clauses, and limits in detail.

Frequently Asked Questions

What units is duration in?

Seconds. A value of 0.45 means 450 milliseconds. Multiply by 1000 in the SELECT clause if you want the output in milliseconds.

Why does my query return only one hour of data?

Without a SINCE clause, NRQL defaults to the last hour. Always include SINCE 1 day ago (or another window) when you want a full day of data.

Can I get more than the default number of facet results?

Yes. Faceted queries return a limited number of results by default. Add an explicit LIMIT (for example, LIMIT 50) to return more applications.

How do I see the trend instead of a single average?

Add TIMESERIES to the query. It buckets the last day into time slices and returns an average per app per bucket, which charts naturally in the query builder or a dashboard.

Conclusion

A single line of NRQL answers the question: SELECT average(duration) FROM Transaction SINCE 1 day ago FACET appName. From there, TIMESERIES shows the trend, WHERE narrows the scope, and percentiles expose tail latency that averages miss. Once the query is working in the query builder, save it to a dashboard so per-application performance stays visible day to day. If you are evaluating tooling for this kind of analysis, New Relic lets you run NRQL directly over your transaction data, and you can explore the platform and pricing at newrelic.com/pricing.

Related Articles