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

Execute an instant query.

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

use prometheus_http_query::{Error, query};

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

    let response = query("http://localhost:9090", q, None, None).await?;

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

    Ok(())
}