diff --git a/harmony/src/modules/application/features/rhob_monitoring.rs b/harmony/src/modules/application/features/rhob_monitoring.rs index 36cc859..d87ef61 100644 --- a/harmony/src/modules/application/features/rhob_monitoring.rs +++ b/harmony/src/modules/application/features/rhob_monitoring.rs @@ -64,12 +64,13 @@ impl< application: self.application.clone(), receivers: self.alert_receiver.clone(), }; + let domain = topology + .get_domain("ntfy") + .await + .map_err(|e| format!("could not get domain {e}"))?; let ntfy = NtfyScore { namespace: namespace.clone(), - host: topology - .get_domain("ntfy") - .await - .map_err(|e| format!("Could not get domain {e}"))?, + host: domain.clone(), }; ntfy.interpret(&Inventory::empty(), topology) .await @@ -91,27 +92,33 @@ impl< .replace("=", ""); debug!("ntfy_default_auth_param: {ntfy_default_auth_param}"); - let ntfy_receiver = WebhookReceiver { name: "ntfy-webhook".to_string(), url: Url::Url( url::Url::parse( format!( - "http://ntfy.{}.svc.cluster.local/rust-web-app?auth={ntfy_default_auth_param}", - namespace.clone() + "http://{domain}/{}?auth={ntfy_default_auth_param}", + self.application.name() ) .as_str(), ) .unwrap(), ), }; - + debug!( + "ntfy webhook receiver \n{:#?}\nntfy topic: {}", + ntfy_receiver.clone(), + self.application.name() + ); alerting_score.receivers.push(Box::new(ntfy_receiver)); alerting_score .interpret(&Inventory::empty(), topology) .await .map_err(|e| e.to_string())?; - Ok(InstallationOutcome::success()) + Ok(InstallationOutcome::success_with_details(vec![format!( + "ntfy topic: {}", + self.application.name() + )])) } fn name(&self) -> String { "Monitoring".to_string() diff --git a/harmony/src/modules/application/rust.rs b/harmony/src/modules/application/rust.rs index ddbf0a8..4874798 100644 --- a/harmony/src/modules/application/rust.rs +++ b/harmony/src/modules/application/rust.rs @@ -257,6 +257,7 @@ impl RustWebapp { ".harmony_generated", "harmony", "node_modules", + "Dockerfile.harmony", ]; let mut entries: Vec<_> = WalkDir::new(project_root) .into_iter() diff --git a/harmony/src/modules/monitoring/alert_channel/discord_alert_channel.rs b/harmony/src/modules/monitoring/alert_channel/discord_alert_channel.rs index 748c677..8bef793 100644 --- a/harmony/src/modules/monitoring/alert_channel/discord_alert_channel.rs +++ b/harmony/src/modules/monitoring/alert_channel/discord_alert_channel.rs @@ -35,6 +35,24 @@ pub struct DiscordWebhook { #[async_trait] impl AlertReceiver for DiscordWebhook { async fn install(&self, sender: &RHOBObservability) -> Result { + let ns = sender.namespace.clone(); + let secret_name = format!("{}-secret", self.name.clone()); + let webhook_key = format!("{}", self.url.clone()); + + let mut string_data = BTreeMap::new(); + string_data.insert("webhook-url".to_string(), webhook_key.clone()); + + let secret = Secret { + metadata: kube::core::ObjectMeta { + name: Some(secret_name.clone()), + ..Default::default() + }, + string_data: Some(string_data), + type_: Some("Opaque".to_string()), + ..Default::default() + }; + + let _ = sender.client.apply(&secret, Some(&ns)).await; let spec = crate::modules::monitoring::kube_prometheus::crd::rhob_alertmanager_config::AlertmanagerConfigSpec { data: json!({ "route": { @@ -43,9 +61,14 @@ impl AlertReceiver for DiscordWebhook { "receivers": [ { "name": self.name, - "webhookConfigs": [ + "discordConfigs": [ { - "url": self.url, + "apiURL": { + "name": secret_name, + "key": "webhook-url", + }, + "title": "{{ template \"discord.default.title\" . }}", + "message": "{{ template \"discord.default.message\" . }}" } ] } diff --git a/harmony/src/modules/monitoring/alert_channel/webhook_receiver.rs b/harmony/src/modules/monitoring/alert_channel/webhook_receiver.rs index 52124ff..1b20df3 100644 --- a/harmony/src/modules/monitoring/alert_channel/webhook_receiver.rs +++ b/harmony/src/modules/monitoring/alert_channel/webhook_receiver.rs @@ -43,6 +43,11 @@ impl AlertReceiver for WebhookReceiver { "webhookConfigs": [ { "url": self.url, + "httpConfig": { + "tlsConfig": { + "insecureSkipVerify": true + } + } } ] } diff --git a/harmony/src/modules/prometheus/alerts/k8s/pod.rs b/harmony/src/modules/prometheus/alerts/k8s/pod.rs index d116403..e1dba28 100644 --- a/harmony/src/modules/prometheus/alerts/k8s/pod.rs +++ b/harmony/src/modules/prometheus/alerts/k8s/pod.rs @@ -42,7 +42,7 @@ pub fn alert_pod_not_ready() -> PrometheusAlertRule { PrometheusAlertRule { alert: "PodNotReady".into(), expr: "kube_pod_status_ready{condition=\"true\"} == 0".into(), - r#for: Some("2m".into()), + r#for: Some("30s".into()), labels: HashMap::from([("severity".into(), "warning".into())]), annotations: HashMap::from([ ("summary".into(), "Pod is not ready".into()),