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