Module aggregation

Module aggregation 

Source
Expand description

Aggregation grouping clause parsing for PromQL.

This module handles parsing the grouping clauses used with aggregation operators:

  • by (label1, label2) - Group by specific labels, dropping all others
  • without (label1, label2) - Drop specific labels, keeping all others

§Supported Aggregation Operators

These operators support grouping clauses: sum, avg, count, min, max, group, stddev, stdvar, topk, bottomk, count_values, quantile, limitk, limit_ratio

§Examples

use rusty_promql_parser::parser::aggregation::{grouping, GroupingAction};

let (rest, g) = grouping("by (job, instance)").unwrap();
assert!(rest.is_empty());
assert_eq!(g.action, GroupingAction::By);
assert_eq!(g.labels, vec!["job", "instance"]);

let (rest, g) = grouping("without (instance)").unwrap();
assert!(rest.is_empty());
assert_eq!(g.action, GroupingAction::Without);

Structs§

Grouping
Grouping clause for aggregation expressions.

Enums§

GroupingAction
The action for aggregation grouping: by or without.

Functions§

grouping
Parse a grouping clause: by (label1, label2) or without (label1, label2)