pub fn holt_winters(
    vector: RangeVector,
    sf: f64,
    tf: f64
) -> Result<InstantVector, Error>
Expand description

Apply the PromQL holt_winters function.

use prometheus_http_query::{Client, Selector, RangeVector};
use prometheus_http_query::functions::holt_winters;
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")
        .with("job", "prometheus")
        .with("handler", "/metrics")
        .range("1m")?
        .try_into()?;

    let q = holt_winters(vector, 0.8, 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(())
}