diff --git a/src/parser/function.rs b/src/parser/function.rs index 5dc5e9b..c74cd6f 100644 --- a/src/parser/function.rs +++ b/src/parser/function.rs @@ -264,6 +264,14 @@ lazy_static! { ValueType::Vector, false ), + // MetricsQL extension. + function!( + "l2_over_time", + vec![ValueType::Matrix], + 0, + ValueType::Vector, + false + ), function!("exp", vec![ValueType::Vector], 0, ValueType::Vector, false), function!( "first_over_time", diff --git a/src/parser/parse.rs b/src/parser/parse.rs index 305f25a..7010a24 100644 --- a/src/parser/parse.rs +++ b/src/parser/parse.rs @@ -1369,6 +1369,18 @@ mod tests { ) }) }), + ("l2_over_time(some_metric[5m])", { + Expr::new_matrix_selector( + Expr::from(VectorSelector::from("some_metric")), + duration::MINUTE_DURATION * 5, + ) + .and_then(|ex| { + Expr::new_call( + get_function("l2_over_time").unwrap(), + FunctionArgs::new_args(ex), + ) + }) + }), ("round(some_metric)", { let ex = Expr::from(VectorSelector::from("some_metric")); Expr::new_call(get_function("round").unwrap(), FunctionArgs::new_args(ex))