Function prometheus_http_query::aggregations::group[][src]

pub fn group<'a>(
    vector: InstantVector,
    labels: Option<Aggregate<'a>>
) -> InstantVector
Expand description

Use the group aggregation operator on an instant vector.

use prometheus_http_query::{Selector, InstantVector, Aggregate};
use prometheus_http_query::aggregations::group;
use std::convert::TryInto;

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

    let result = group(vector, Some(Aggregate::Without(&["mode"])));

    assert_eq!(result.to_string(), String::from("group without (mode) (node_cpu_seconds_total)"));

    Ok(())
}