[][src]Struct promql::Vector

pub struct Vector {
    pub labels: Vec<LabelMatch>,
    pub range: Option<usize>,
    pub offset: Option<usize>,
}

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::types::CompleteByteSlice;
use nom::IResult;

assert_eq!(
	parse("foo{bar='baz'}".as_bytes(), false),
	Ok(Node::Vector(Vector {
		labels: vec![
			// this is the filter for the metric name 'foo'
			LabelMatch { name: "__name__".to_string(), op: Eq, value: "foo".to_string(), },
			// here go all the other filters
			LabelMatch { name: "bar".to_string(),      op: Eq, value: "baz".to_string(), },
		],
		range: None, offset: None,
	}))
);

Fields

labels: Vec<LabelMatch>

Set of label filters

range: Option<usize>

Range for range vectors, in seconds, e.g. Some(300) for [5m]

offset: Option<usize>

Offset in seconds, e.g. Some(3600) for offset 1h

Trait Implementations

impl Debug for Vector[src]

impl PartialEq<Vector> for Vector[src]

impl StructuralPartialEq for Vector[src]

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.