pub struct Vector {
pub labels: Vec<LabelMatch>,
pub range: Option<f32>,
pub offset: Option<f32>,
}
Expand description
This struct represents both instant and range vectors.
Note that there’s no field for metric name: not only it is optional (as in {instance="localhost", job="foo"}
), metric names can actually be matched using special label called __name__
(e.g. {__name__=~"megaexporter_.+"}
), so it only makes sense to parse label names into the corresponding label filter, like so:
use promql::*;
use promql::LabelMatchOp::*; // Eq
use nom::IResult;
assert_eq!(
parse("foo{bar='baz'}".as_bytes(), &Default::default()),
Ok(Node::Vector(Vector {
labels: vec![
// this is the filter for the metric name 'foo'
LabelMatch { name: "__name__".to_string(), op: Eq, value: b"foo".to_vec(), },
// here go all the other filters
LabelMatch { name: "bar".to_string(), op: Eq, value: b"baz".to_vec(), },
],
range: None, offset: None,
}))
);
Fields§
§labels: Vec<LabelMatch>
Set of label filters
range: Option<f32>
Range for range vectors, in seconds, e.g. Some(300.)
for [5m]
offset: Option<f32>
Offset in seconds, e.g. Some(3600.)
for offset 1h
Trait Implementations§
source§impl PartialEq for Vector
impl PartialEq for Vector
impl StructuralPartialEq for Vector
Auto Trait Implementations§
impl RefUnwindSafe for Vector
impl Send for Vector
impl Sync for Vector
impl Unpin for Vector
impl UnwindSafe for Vector
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more