Function prometheus_http_query::aggregations::group
source · [−]pub fn group(
vector: InstantVector,
labels: Option<Aggregate<'_>>
) -> InstantVectorExpand description
Use the group aggregation operator on an instant vector.
use prometheus_http_query::{Client, Selector, InstantVector};
use prometheus_http_query::aggregations::group;
use std::convert::TryInto;
#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), prometheus_http_query::Error> {
let client = Client::default();
let vector: InstantVector = Selector::new()
.metric("prometheus_http_requests_total")
.try_into()?;
let q = group(vector, None);
let response = client.query(q, None, None).await?;
let value = response.as_instant()
.unwrap()
.get(0)
.unwrap()
.sample()
.value();
assert_eq!(value, 1.0);
Ok(())
}