pub struct PrometheusClient { /* private fields */ }Expand description
Prometheus client for querying historical metrics.
Implementations§
Source§impl PrometheusClient
impl PrometheusClient
Sourcepub fn new(url: &str) -> Result<Self, PrometheusError>
pub fn new(url: &str) -> Result<Self, PrometheusError>
Create a new Prometheus client without authentication.
This is the default and works for kubectl port-forward connections
where no authentication is needed.
Sourcepub fn with_auth(
url: &str,
auth: PrometheusAuth,
) -> Result<Self, PrometheusError>
pub fn with_auth( url: &str, auth: PrometheusAuth, ) -> Result<Self, PrometheusError>
Create a new Prometheus client with optional authentication.
Use this for externally exposed Prometheus instances that require auth.
Sourcepub async fn is_available(&self) -> bool
pub async fn is_available(&self) -> bool
Check if Prometheus is reachable.
Sourcepub async fn get_container_history(
&self,
namespace: &str,
pod_pattern: &str,
container: &str,
time_range: &str,
) -> Result<ContainerHistory, PrometheusError>
pub async fn get_container_history( &self, namespace: &str, pod_pattern: &str, container: &str, time_range: &str, ) -> Result<ContainerHistory, PrometheusError>
Get container CPU/memory history.
Sourcepub async fn get_workload_history(
&self,
namespace: &str,
workload_name: &str,
workload_kind: &str,
time_range: &str,
) -> Result<WorkloadHistory, PrometheusError>
pub async fn get_workload_history( &self, namespace: &str, workload_name: &str, workload_kind: &str, time_range: &str, ) -> Result<WorkloadHistory, PrometheusError>
Get history for all containers in a workload.
Sourcepub fn generate_recommendation(
history: &ContainerHistory,
current_cpu_request: Option<u64>,
current_memory_request: Option<u64>,
safety_margin_pct: u8,
) -> HistoricalRecommendation
pub fn generate_recommendation( history: &ContainerHistory, current_cpu_request: Option<u64>, current_memory_request: Option<u64>, safety_margin_pct: u8, ) -> HistoricalRecommendation
Generate right-sizing recommendations based on historical data.
Auto 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<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> 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> 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 moreCreates a shared type from an unshared type.