pub struct PrometheusClient { /* private fields */ }Expand description
Prometheus client with caching
Implementations§
Source§impl PrometheusClient
impl PrometheusClient
Sourcepub fn with_cache_ttl(prometheus_url: String, cache_ttl: Duration) -> Self
pub fn with_cache_ttl(prometheus_url: String, cache_ttl: Duration) -> Self
Create a client with custom cache TTL
Sourcepub async fn query(&self, query: &str) -> Result<PrometheusResponse>
pub async fn query(&self, query: &str) -> Result<PrometheusResponse>
Execute an instant query
Sourcepub async fn query_range(
&self,
query: &str,
start: i64,
end: i64,
step: &str,
) -> Result<PrometheusResponse>
pub async fn query_range( &self, query: &str, start: i64, end: i64, step: &str, ) -> Result<PrometheusResponse>
Execute a range query
Sourcepub async fn clear_cache(&self)
pub async fn clear_cache(&self)
Clear the cache
Sourcepub fn extract_single_value(response: &PrometheusResponse) -> Option<f64>
pub fn extract_single_value(response: &PrometheusResponse) -> Option<f64>
Extract single value from query result
Sourcepub fn extract_values(response: &PrometheusResponse) -> Vec<(String, f64)>
pub fn extract_values(response: &PrometheusResponse) -> Vec<(String, f64)>
Extract multiple values from query result
Sourcepub fn extract_time_series(
response: &PrometheusResponse,
) -> Vec<(String, Vec<(i64, f64)>)>
pub fn extract_time_series( response: &PrometheusResponse, ) -> Vec<(String, Vec<(i64, f64)>)>
Extract time series data from range query
Sourcepub async fn health_check(&self) -> bool
pub async fn health_check(&self) -> bool
Check if Prometheus is reachable
Trait Implementations§
Source§impl Clone for PrometheusClient
impl Clone for PrometheusClient
Source§fn clone(&self) -> PrometheusClient
fn clone(&self) -> PrometheusClient
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for PrometheusClient
impl !RefUnwindSafe for PrometheusClient
impl Send for PrometheusClient
impl Sync for PrometheusClient
impl Unpin for PrometheusClient
impl !UnwindSafe for PrometheusClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> GetSetFdFlags for T
impl<T> GetSetFdFlags for T
Source§fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
fn get_fd_flags(&self) -> Result<FdFlags, Error>where
T: AsFilelike,
Query the “status” flags for the
self file descriptor.Source§fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
fn new_set_fd_flags(&self, fd_flags: FdFlags) -> Result<SetFdFlags<T>, Error>where
T: AsFilelike,
Source§fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
fn set_fd_flags(&mut self, set_fd_flags: SetFdFlags<T>) -> Result<(), Error>where
T: AsFilelike,
Set the “status” flags for the
self file descriptor. Read moreSource§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request