percentiles_array

This page explains how to use the percentiles_array function in APL.

Use the percentiles_array aggregation function in APL to calculate multiple percentile values over a numeric expression in one pass. This function is useful when you want to understand the distribution of numeric data points, such as response times or durations, by summarizing them at several key percentiles like the 25th, 50th, and 95th.

You can use percentiles_array to:

  • Analyze latency or duration metrics across requests or operations.
  • Identify performance outliers.
  • Visualize percentile distributions in dashboards.

Usage

Syntax

percentiles_array(Field, Percentile1, Percentile2, ...)

Parameters

  • Field is the name of the field for which you want to compute percentile values.
  • Percentile1, Percentile2, ... are numeric percentile values between 0 and 100.

Returns

An array of numbers where each element is the value at the corresponding percentile.

Use case examples

Use percentiles_array to understand the spread of request durations per HTTP method, highlighting performance variability.

Query

['sample-http-logs']
| summarize percentiles_array(req_duration_ms, 25, 50, 95) by method

Run in Playground

Output

methodP25P50P95
GET0.3981 ms0.7352 ms1.981 ms
POST0.3261 ms0.7162 ms2.341 ms
PUT0.3324 ms0.7772 ms1.341 ms
DELETE0.2332 ms0.4652 ms1.121 ms

This query calculates the 25th, 50th, and 95th percentiles of request durations for each HTTP method. It helps identify performance differences between different methods.

Use percentiles_array to analyze the distribution of span durations by service to detect potential bottlenecks.

Query

['otel-demo-traces']
| summarize percentiles_array(duration, 50, 90, 99) by ['service.name']

Run in Playground

Output

service.nameP50P90P99P99
recommendationservice1.96 ms2.965 ms3.477 ms3.477 ms
frontendproxy3.767 ms13.101 ms39.735 ms39.735 ms
shippingservice2.119 ms3.085 ms9.739 ms9.739 ms
checkoutservice1.454 ms12.342 ms29.542 ms29.542 ms

This query shows latency patterns across services by computing the median, 90th, and 99th percentile of span durations.

Use percentiles_array to assess outlier response times per status code, which can reveal abnormal activity or service issues.

Query

['sample-http-logs']
| summarize percentiles_array(req_duration_ms, 50, 95, 99) by status

Run in Playground

Output

statusP50P95P99
2000.7352 ms1.981 ms2.612 ms
2010.7856 ms1.356 ms2.234 ms
3010.8956 ms1.547 ms2.546 ms
5000.6587 ms1.856 ms2.856 ms

This query helps identify whether requests resulting in errors (like 500) are significantly slower than successful ones.

  • avg: Returns the average value. Use it when a single central tendency is sufficient.
  • percentile: Returns a single percentile value. Use it when you only need one percentile.
  • percentile_if: Returns a single percentile value for the records that satisfy a condition.
  • percentiles_arrayif: Returns an array of percentile values for the records that satisfy a condition.
  • sum: Returns the sum of a numeric column.

Other query languages