pub fn present_over_time(vector: RangeVector) -> InstantVector
Expand description

Apply the PromQL present_over_time function.

use prometheus_http_query::{Client, Selector, RangeVector};
use prometheus_http_query::functions::present_over_time;
use std::convert::TryInto;

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), prometheus_http_query::Error> {
    let client = Client::default();
    let vector: RangeVector = Selector::new()
        .metric("prometheus_http_requests_total")
        .range("1m")?
        .try_into()?;

    let q = present_over_time(vector);

    let response = client.query(q, None, None).await?;
    let value = response.as_instant()
        .unwrap()
        .get(0)
        .unwrap()
        .sample()
        .value();

    assert!(value.is_normal());
    Ok(())
}