pub async fn query_range(
    host: &str,
    query: impl ToString,
    start: i64,
    end: i64,
    step: f64,
    timeout: Option<i64>
) -> Result<PromqlResult, Error>
Expand description

Execute a range query.

This is just a convenience function for one-off requests, see Client::query_range.

use prometheus_http_query::{Error, query_range};

#[tokio::main(flavor = "current_thread")]
async fn main() -> Result<(), Error> {
    let q = "sum(prometheus_http_requests_total)";

    let response = query_range("http://localhost:9090", q, 1648373100, 1648373300, 10.0, None).await?;

    assert!(response.as_range().is_some());

    Ok(())
}