Using NRQL, you can split your query results into buckets that cover certain ranges using the
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_TYPEFACET 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
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 40 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 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.