Function prometheus_http_query::functions::year[][src]

pub fn year(vector: InstantVector) -> InstantVector
Expand description

Apply the PromQL year function.

use prometheus_http_query::{Selector, InstantVector};
use prometheus_http_query::functions::year;
use std::convert::TryInto;

fn main() -> Result<(), prometheus_http_query::Error> {
    let vector: InstantVector = Selector::new()
        .metric("some_metric")?
        .with("some_label", "some_value")
        .try_into()?;

    let result = year(vector);

    assert_eq!(&result.to_string(), "year(some_metric{some_label=\"some_value\"})");

    Ok(())
}