histogram_fraction

Description

Calculates the CDF (Cumulative Distribution Function) of the distribution in a histogram-like object at the specified value.

Given an histogram-like object (OTel histogram, OTel exponential histogram, or t-digest), and an input value, returns the fraction of the distribution that is less than or equal to the input value.

As any other function that operates on histogram-like objects, the resulting fraction is an approximation.

Currently, the only supported histogram-like type is tdigest.

Return type

float64

Domain

This is a scalar function (calculates a single output value for a single input row.)

Categories

Usage

histogram_fraction(histogram, value)

Argument

Type

Optional

Repeatable

Restrictions

histogram

histogram like

no

no

none

value

numeric or duration

no

no

constant

Examples

align 5m, o: histogram_combine(m_tdigest("duration"))
aggregate o: histogram_fraction(histogram_combine(o), 10m), group_by(^Cluster...)

align aggregates tdigest metric “duration” over time into 5 minute time bins.

aggregate computes the fraction of the distribution that is less than or equal to 10 minutes for each cluster.