Function prometheus_http_query::functions::predict_linear
source · [−]pub fn predict_linear(vector: RangeVector, seconds: f64) -> InstantVector
Expand description
Apply the PromQL predict_linear
function.
use prometheus_http_query::{Client, Selector, RangeVector};
use prometheus_http_query::functions::predict_linear;
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 = predict_linear(vector, 300.0);
let response = client.query(q, None, None).await?;
let value = response.as_instant()
.unwrap()
.get(0)
.unwrap()
.sample()
.value();
assert!(value.is_normal());
Ok(())
}