Split your Insights data into buckets

You can split your data 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.

SELECT function(attribute) 
    FROM source 
    FACET buckets(attribute, ceiling, number of buckets)

Bucketing can be used with any attribute that is stored as a numerical value in the New Relic Insights event database.

For more information, check out the New Relic University tutorial Advanced Segmentation. Or, go directly to the full online course Writing NRQL Queries.

Bucketing example

To create a chart that shows the average duration of ranges of database calls:

  1. Create a NRQL statement with a SELECT statement for an attribute; for example, SELECT average(duration).
  2. Add a FACET clause that facets on buckets for another attribute; for example, buckets(databaseCallCount,400,10).

This query computes the average duration for each of the 10 buckets, with an upper limit of 400. All values above our upper limit of 400 are grouped in the last bucket, “>=360.0”.

SELECT average(duration) FROM Transaction 
    SINCE 12 hours ago 
    FACET buckets(databaseCallCount, 400, 10)

This query returns the following results in Insights:


insights.newrelic.com: Here is 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.

For more help

Recommendations for learning more: