Function prometheus_http_query::query_range
source · pub fn query_range(
host: &str,
query: impl ToString,
start: i64,
end: i64,
step: f64
) -> Result<RangeQueryBuilder, 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)?.get().await?;
assert!(response.data().as_matrix().is_some());
// Or make a POST request.
let response = query_range("http://localhost:9090", q, 1648373100, 1648373300, 10.0)?.post().await?;
assert!(response.data().as_matrix().is_some());
Ok(())
}