Function prometheus_http_query::functions::absent
source · [−]pub fn absent(vector: InstantVector) -> InstantVector
Expand description
Apply the PromQL absent
function.
use prometheus_http_query::{Client, Selector, InstantVector};
use prometheus_http_query::functions::absent;
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("up")
.with("job", "foobar")
.try_into()?;
let q = absent(vector);
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(())
}