forked from NationTech/harmony
		
	fix: properly configured discord alert receiver corrected domain and topic name for ntfy
This commit is contained in:
		
							parent
							
								
									9b889f71da
								
							
						
					
					
						commit
						49dad343ad
					
				| @ -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,21 +92,24 @@ 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) | ||||
|  | ||||
| @ -224,6 +224,7 @@ impl RustWebapp { | ||||
|                 ".harmony_generated", | ||||
|                 "harmony", | ||||
|                 "node_modules", | ||||
|                 "Dockerfile.harmony", | ||||
|             ]; | ||||
|             let mut entries: Vec<_> = WalkDir::new(project_root) | ||||
|                 .into_iter() | ||||
|  | ||||
| @ -35,6 +35,24 @@ pub struct DiscordWebhook { | ||||
| #[async_trait] | ||||
| impl AlertReceiver<RHOBObservability> for DiscordWebhook { | ||||
|     async fn install(&self, sender: &RHOBObservability) -> Result<Outcome, InterpretError> { | ||||
|         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<RHOBObservability> 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\" . }}" | ||||
|                             } | ||||
|                         ] | ||||
|                     } | ||||
|  | ||||
| @ -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()), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user