From 0e7cf24dbb5f82060b7010c8b12ef6b19494db7e Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Thu, 6 Nov 2025 10:31:25 +0100 Subject: [PATCH] Add exclude_email_metrics configuration option - Add exclude_email_metrics field to AgentConfig for filtering email notifications - Metrics matching excluded names skip notification processing but still appear in dashboard - Optional field with serde(default) for backward compatibility - Bump version to 0.1.56 --- agent/Cargo.toml | 2 +- agent/src/agent.rs | 7 +++++++ agent/src/config/mod.rs | 3 +++ dashboard/Cargo.toml | 2 +- shared/Cargo.toml | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/agent/Cargo.toml b/agent/Cargo.toml index 0b634ed..9b7edfc 100644 --- a/agent/Cargo.toml +++ b/agent/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-agent" -version = "0.1.55" +version = "0.1.56" edition = "2021" [dependencies] diff --git a/agent/src/agent.rs b/agent/src/agent.rs index 67e13a1..60a80ac 100644 --- a/agent/src/agent.rs +++ b/agent/src/agent.rs @@ -201,6 +201,12 @@ impl Agent { async fn process_metrics(&mut self, metrics: &[Metric]) -> bool { let mut status_changed = false; for metric in metrics { + // Filter excluded metrics from email notification processing only + if self.config.exclude_email_metrics.contains(&metric.name) { + debug!("Excluding metric '{}' from email notification processing", metric.name); + continue; + } + if self.host_status_manager.process_metric(metric, &mut self.notification_manager).await { status_changed = true; } @@ -226,6 +232,7 @@ impl Agent { format!("v{}", env!("CARGO_PKG_VERSION")) } + async fn handle_commands(&mut self) -> Result<()> { // Try to receive commands (non-blocking) match self.zmq_handler.try_receive_command() { diff --git a/agent/src/config/mod.rs b/agent/src/config/mod.rs index baabc12..719948b 100644 --- a/agent/src/config/mod.rs +++ b/agent/src/config/mod.rs @@ -17,6 +17,9 @@ pub struct AgentConfig { pub notifications: NotificationConfig, pub status_aggregation: HostStatusConfig, pub collection_interval_seconds: u64, + /// List of metric names to exclude from email notifications + #[serde(default)] + pub exclude_email_metrics: Vec, } /// ZMQ communication configuration diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 5853a2e..243ddfa 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard" -version = "0.1.55" +version = "0.1.56" edition = "2021" [dependencies] diff --git a/shared/Cargo.toml b/shared/Cargo.toml index 2a3f2fc..83bcf9d 100644 --- a/shared/Cargo.toml +++ b/shared/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cm-dashboard-shared" -version = "0.1.55" +version = "0.1.56" edition = "2021" [dependencies]