Struct promql::Vector [] [src]

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!(
    vector(CompleteByteSlice("foo{bar='baz'}".as_bytes())),
    Ok((CompleteByteSlice(b""), 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

Set of label filters

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

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

Trait Implementations

impl Debug for Vector
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for Vector
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.