monitoring-alerting #30

Merged
wjro merged 12 commits from monitoring-alerting into master 2025-05-06 17:50:57 +00:00
3 changed files with 15 additions and 3 deletions
Showing only changes of commit d9921b857b - Show all commits

View File

@ -45,6 +45,8 @@ impl MonitoringAlertingTopology {
for ns in &["monitoring", "openshift-monitoring"] { for ns in &["monitoring", "openshift-monitoring"] {
let pods: Api<Pod> = Api::namespaced(client.clone(), ns); let pods: Api<Pod> = Api::namespaced(client.clone(), ns);
//TODO hardcoding the label is a problem
//check all pods are ready
let lp = ListParams::default().labels("app.kubernetes.io/name=prometheus"); let lp = ListParams::default().labels("app.kubernetes.io/name=prometheus");
match pods.list(&lp).await { match pods.list(&lp).await {

View File

@ -31,7 +31,7 @@ additionalPrometheusRules:
namespace: Some(NonBlankString::from_str(ns).unwrap()), namespace: Some(NonBlankString::from_str(ns).unwrap()),
release_name: NonBlankString::from_str("kube-prometheus").unwrap(), release_name: NonBlankString::from_str("kube-prometheus").unwrap(),
chart_name: NonBlankString::from_str( chart_name: NonBlankString::from_str(
"https://prometheus-community.github.io/helm-charts" "oci://registry-1.docker.io/bitnamicharts/kube-prometheus"
//use kube prometheus chart which includes grafana, prometheus, alert //use kube prometheus chart which includes grafana, prometheus, alert
//manager, etc //manager, etc
) )

View File

@ -1,4 +1,5 @@
use async_trait::async_trait; use async_trait::async_trait;
use log::info;
use serde::Serialize; use serde::Serialize;
use crate::{ use crate::{
@ -14,6 +15,9 @@ use super::kube_prometheus::kube_prometheus_score;
#[derive(Debug)] #[derive(Debug)]
pub struct MonitoringAlertingStackScore { pub struct MonitoringAlertingStackScore {
//TODO add documenation to explain why its here
//keeps it open for the end user to specify which stack they want
//if it isnt default kube-prometheus
pub monitoring_stack: Vec<Box<dyn Score<MonitoringAlertingTopology>>>, pub monitoring_stack: Vec<Box<dyn Score<MonitoringAlertingTopology>>>,
pub namespace: String, pub namespace: String,
} }
@ -102,14 +106,20 @@ impl <T: Topology> Interpret<T> for MonitoringAlertingStackInterpret {
) -> Result<Outcome, InterpretError> { ) -> Result<Outcome, InterpretError> {
let inventory = Inventory::autoload(); let inventory = Inventory::autoload();
let topology = MonitoringAlertingTopology::new(); let topology = MonitoringAlertingTopology::new();
let mut maestro = match Maestro::initialize(inventory, topology).await { let maestro = match Maestro::initialize(inventory, topology).await {
Ok(m) => m, Ok(m) => m,
Err(e) => { Err(e) => {
println!("failed to initialize Maestro: {}", e); println!("failed to initialize Maestro: {}", e);
std::process::exit(1); std::process::exit(1);
} }
}; };
maestro.register_all(self.score.monitoring_stack.clone());
let scores_vec = self.score.monitoring_stack.clone();
for s in scores_vec{
info!("Running: {}", s.name());
maestro.interpret(s).await?;
}
Ok(Outcome::success(format!( Ok(Outcome::success(format!(
"monitoring stack installed in {} namespace", "monitoring stack installed in {} namespace",
self.score.namespace self.score.namespace