Struct prometheus_http_query::Client [−][src]
pub struct Client { /* fields omitted */ }
Expand description
A client used to execute queries. It uses a reqwest::Client internally that manages connections for us.
Implementations
Create a Client that connects to a Prometheus instance at the given FQDN/domain and port, using either HTTP or HTTPS.
Note that possible errors regarding domain name resolution or connection establishment will only be propagated from the underlying reqwest::Client when a query is executed.
use prometheus_http_query::{Client, Scheme}; let client = Client::new(Scheme::Http, "localhost", 9090);
Perform an instant query using a crate::RangeVector or crate::InstantVector.
use prometheus_http_query::{Client, Scheme, InstantVector, Selector, Aggregate}; use prometheus_http_query::aggregations::sum; use std::convert::TryInto; let client = Client::new(Scheme::Http, "localhost", 9090); let v: InstantVector = Selector::new() .metric("cpu_seconds_total") .unwrap() .try_into() .unwrap(); let s = sum(v, Some(Aggregate::By(&["cpu"]))); let response = tokio_test::block_on( async { client.query(s, None, None).await }); assert!(response.is_ok());
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl !UnwindSafe for Client