pub struct AlertRule {
pub name: String,
pub severity: AlertSeverity,
pub kind: AlertRuleKind,
pub cooldown: Duration,
}Expand description
A configured alerting rule.
Each rule carries a unique name, a AlertSeverity, the monitored
AlertRuleKind, and a cooldown that suppresses repeat alerts while the
rule remains continuously tripped.
Fields§
§name: StringUnique rule identifier (also used as the alert’s rule_name).
severity: AlertSeveritySeverity attached to alerts produced by this rule.
kind: AlertRuleKindThe condition being monitored.
cooldown: DurationMinimum time between successive firing alerts for this rule.
Implementations§
Source§impl AlertRule
impl AlertRule
Sourcepub fn failure_rate(
name: impl Into<String>,
severity: AlertSeverity,
trip_threshold: f64,
) -> Self
pub fn failure_rate( name: impl Into<String>, severity: AlertSeverity, trip_threshold: f64, ) -> Self
Build a failure-rate rule. By default the clear threshold equals the trip
threshold (no hysteresis), the window is 60s, min_samples is 1 and the
cooldown is 60s; adjust with the builder methods.
Sourcepub fn queue_depth(
name: impl Into<String>,
severity: AlertSeverity,
trip_depth: u64,
) -> Self
pub fn queue_depth( name: impl Into<String>, severity: AlertSeverity, trip_depth: u64, ) -> Self
Build a queue-depth rule. Clear depth defaults to the trip depth.
Sourcepub fn no_heartbeat(
name: impl Into<String>,
severity: AlertSeverity,
timeout: Duration,
) -> Self
pub fn no_heartbeat( name: impl Into<String>, severity: AlertSeverity, timeout: Duration, ) -> Self
Build a no-heartbeat rule.
Sourcepub fn with_cooldown(self, cooldown: Duration) -> Self
pub fn with_cooldown(self, cooldown: Duration) -> Self
Set the cooldown between repeated firing alerts.
Sourcepub fn with_clear_threshold(self, clear: f64) -> Self
pub fn with_clear_threshold(self, clear: f64) -> Self
Set the clear threshold for a failure-rate rule (enables hysteresis).
Sourcepub fn with_window(self, window: Duration) -> Self
pub fn with_window(self, window: Duration) -> Self
Set the sliding window for a failure-rate rule.
Sourcepub fn with_min_samples(self, min_samples: u64) -> Self
pub fn with_min_samples(self, min_samples: u64) -> Self
Set the minimum samples for a failure-rate rule.
Sourcepub fn with_clear_depth(self, clear: u64) -> Self
pub fn with_clear_depth(self, clear: u64) -> Self
Set the clear depth for a queue-depth rule (enables hysteresis).