Function prometheus_http_query::aggregations::max
source · [−]pub fn max(
vector: InstantVector,
labels: Option<Aggregate<'_>>
) -> InstantVector
Expand description
Use the max
aggregation operator on an instant vector.
use prometheus_http_query::{Client, Selector, InstantVector, Aggregate};
use prometheus_http_query::aggregations::max;
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 = max(vector, Some(Aggregate::By(&["code"])));
let response = client.query(q, None, None).await?;
let first_item = response.as_instant()
.unwrap()
.get(0);
assert!(first_item.is_some());
Ok(())
}