matrix_selector

Function matrix_selector 

Source
pub fn matrix_selector(input: &str) -> IResult<&str, MatrixSelector>
Expand description

Parse a matrix selector (range vector)

A matrix selector consists of a vector selector followed by a range duration in square brackets.

ยงExamples

use rusty_promql_parser::parser::selector::matrix_selector;

// Simple metric with range
let (rest, sel) = matrix_selector("http_requests_total[5m]").unwrap();
assert!(rest.is_empty());
assert_eq!(sel.name(), Some("http_requests_total"));
assert_eq!(sel.range_millis(), 5 * 60 * 1000);

// With label matchers
let (rest, sel) = matrix_selector(r#"http_requests_total{job="api"}[1h]"#).unwrap();
assert!(rest.is_empty());
assert_eq!(sel.matchers().len(), 1);