This page explains how to query OpenTelemetry histogram and summary metrics using MPL.
Unlike other OpenTelemetry (OTel) metric types, a histogram or summary metric doesn't hold a single measurement. Each one carries several components that mean different things, such as an observation count alongside a distribution. Query these metric types with a function that's aware of that shape, or by selecting the component you want.
Query histogram metrics with bucket and an interpolate_ function: interpolate_cumulative_histogram for cumulative temporality, interpolate_delta_histogram for delta temporality. Use them when you want the observation count, the average, or an estimated quantile such as the 90th percentile. For the syntax, see Bucket. For examples, see Sample MPL queries.
MPL has no interpolate_ function for summaries because the producer already computed the quantiles. Instead, select the component you want with the reserved axiom.summary and axiom.quantile tags, and derive anything else with compute.
Divide the sum component by the count component with compute.
APL
( `my-dataset`:`service.request.duration` | where `service.name` == "checkout" | where `axiom.summary` == "sum" | group using sum, `my-dataset`:`service.request.duration` | where `service.name` == "checkout" | where `axiom.summary` == "count" | group using sum)| compute average using /
A summary only contains the quantiles the producer computed. You can select one of them, but you can't derive a quantile that isn't there.
APL
// Median, if the producer emits the 0.5 quantile`my-dataset`:`service.request.duration`| where `service.name` == "checkout"| where `axiom.summary` == "bucket" and `axiom.quantile` == 0.5