To return bucketed results, use the
FACET buckets() clause in a NRQL query. A bucketing query has the structure:
SELECT FUNCTION(ATTRIBUTE) FROM DATA_TYPE FACET buckets(ATTRIBUTE, CEILING_VALUE, NUMBER_OF_BUCKETS)
Bucketing can be used with any attribute that is stored as a numerical value in the New Relic database.
- Create a NRQL statement with a
SELECTstatement for an attribute; for example,
- Add a
FACETclause that facets on
buckets(). For example
buckets(duration, 40, 10). You can also bucket on a different attribute than the one in the
SELECTstatement. 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 400 are grouped in the last bucket,
SELECT average(duration) FROM PageView WHERE pageUrl LIKE 'http://webportal.telco%' SINCE 1 week ago FACET buckets(duration, 40, 10)
This query returns the following 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.