Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelog.d/23994_aggregate_transform.enhancement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The aggregate transform now supports aggregating metrics into Distribution metric types, enabling statistical analysis of metric values over time windows.

authors: jlambatl
8 changes: 8 additions & 0 deletions src/transforms/aggregate/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,14 @@ pub enum AggregationMode {

/// Stdev value of absolute metric; incremental metrics pass through unchanged.
Stdev,

/// Collects the values of absolute metrics into a single sorted distribution; incremental
/// metrics pass through unchanged.
///
/// Gauges and sets (numeric members only) contribute one sample per value, distributions
/// contribute their existing samples, and aggregated histograms contribute one sample at each
/// bucket's upper limit per count in that bucket. Other absolute metric types are ignored.
Distribution,
}

const fn default_mode() -> AggregationMode {
Expand Down
16 changes: 14 additions & 2 deletions src/transforms/aggregate/event_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ impl Aggregate {
let bucket = self.event_time_buckets.entry(bucket_key).or_default();
Self::record_comparison_in_map(bucket, series, data, metadata, mode);
}
AggregationMode::Mean | AggregationMode::Stdev => {
// `will_be_stored` has already guaranteed Absolute + Gauge.
AggregationMode::Mean | AggregationMode::Stdev | AggregationMode::Distribution => {
// `will_be_stored` has already guaranteed Absolute (+ Gauge for Mean/Stdev, or a
// convertible value for Distribution).
//
// Mean/Stdev write samples into `event_time_multi_buckets`;
// an empty entry is also placed in `event_time_buckets` so
Expand Down Expand Up @@ -466,6 +467,17 @@ impl Aggregate {
continue;
}

if matches!(self.config.mode, AggregationMode::Distribution) {
if let Some((data, metadata)) =
Self::distribution_from_entries(&entries)
{
output.push(Event::Metric(Metric::from_parts(
series, data, metadata,
)));
}
continue;
}

let (mut final_sum, mut final_metadata) = entries.first().unwrap().clone();
for (data, metadata) in entries.iter().skip(1) {
if !final_sum.update(data) {
Expand Down
Loading
Loading