Using NRQL, you can split your query results into buckets that cover certain ranges using the buckets
function.
Create bucketed NRQL query
To return bucketed results, use the FACET buckets()
clause in a NRQL query. A bucketing query has this structure:
SELECT FUNCTION(ATTRIBUTE) FROM DATA_TYPE FACET buckets(ATTRIBUTE, CEILING_VALUE, NUMBER_OF_BUCKETS)
You can use bucketed NRQL queries with any attribute stored as a numerical value in the New Relic database.
Bucket query example
- Create a NRQL statement with a
SELECT
statement for an attribute; for example,SELECT average(duration)
. - Add a
FACET
clause that facets onbuckets()
. For examplebuckets(duration, 40, 10)
. You can also bucket on a different attribute than the one in theSELECT
statement. For example, to show the average duration for database calls:buckets(databaseCallCount, 40, 10)
.
This query computes the average duration for a specific page path across 10 buckets, with an upper limit of 40. All values above our upper limit of 40 are grouped in the last bucket, >=36.0
.
SELECT average(duration) FROM PageView WHERE pageUrl LIKE 'http://webportal.telco%' SINCE 1 week ago FACET buckets(duration, 40, 10)
This query returns these results:
Here's an example of a NRQL query with segments broken out into ten buckets. The bottom bucket will include outliers, so you may want to adjust accordingly.