feat/monitoring_alerting #61
@ -1,3 +1,4 @@
|
||||
pub mod alert_channel;
|
||||
pub mod kube_prometheus;
|
||||
pub mod monitoring_alerting;
|
||||
mod monitoring_2;
|
||||
|
59
harmony/src/modules/monitoring/monitoring_2.rs
Normal file
59
harmony/src/modules/monitoring/monitoring_2.rs
Normal file
@ -0,0 +1,59 @@
|
||||
use crate::{score::Score, topology::Topology};
|
||||
|
||||
pub trait AlertSender {}
|
||||
|
||||
struct Prometheus {}
|
||||
|
||||
impl Prometheus {
|
||||
fn configure_receiver(&self, receiver: PrometheusReceiver) -> Result<(), String> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl AlertSender for Prometheus {}
|
||||
|
||||
struct DiscordWebhook;
|
||||
struct PrometheusReceiver;
|
||||
|
||||
impl DiscordWebhook {
|
||||
fn as_prometheus_receiver(&self) -> PrometheusReceiver {
|
||||
PrometheusReceiver {}
|
||||
}
|
||||
}
|
||||
|
||||
impl AlertReceiver for DiscordWebhook {
|
||||
type Sender = Prometheus;
|
||||
|
||||
fn install(&self, sender: &Self::Sender) -> Result<(), String> {
|
||||
sender.configure_receiver(self.as_prometheus_receiver())
|
||||
}
|
||||
}
|
||||
|
||||
pub trait AlertReceiver {
|
||||
type Sender: AlertSender;
|
||||
|
||||
fn install(&self) -> Result<(), String>;
|
||||
}
|
||||
|
||||
struct AlertReceiverConfig<S: AlertSender> {
|
||||
config: String, // Or whatever
|
||||
sender: S,
|
||||
}
|
||||
|
||||
struct DiscordWebhookScore {
|
||||
config: DiscordWebhook,
|
||||
}
|
||||
|
||||
impl<T: Topology> Score<T> for DiscordWebhookScore {
|
||||
fn create_interpret(&self) -> Box<AlertReceiverInterpret> {
|
||||
AlertReceiverInterpret { receiver: Box::new(self.config.clone())}
|
||||
}
|
||||
|
||||
fn name(&self) -> String {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
struct AlertReceiverInterpret {
|
||||
receiver: Box<dyn AlertReceiver>,
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
use async_trait::async_trait;
|
||||
use serde::Serialize;
|
||||
use serde_value::Value;
|
||||
|
||||
use crate::topology::oberservability::monitoring::{AlertChannelConfig, Monitor};
|
||||
use crate::{
|
||||
@ -10,13 +11,74 @@ use crate::{
|
||||
topology::{HelmCommand, Topology},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct MonitoringAlertingScore {
|
||||
#[serde(skip)]
|
||||
pub alert_channel_configs: Option<Vec<Box<dyn AlertChannelConfig>>>,
|
||||
pub trait MonitoringSystem {}
|
||||
|
||||
trait PrometheusReceiver {
|
||||
fn get_config(&self) -> PrometheusReceiverConfig;
|
||||
}
|
||||
|
||||
impl<T: Topology + HelmCommand + Monitor> Score<T> for MonitoringAlertingScore {
|
||||
struct PrometheusReceiverConfig {
|
||||
config: Value, // either a serde Value or a more specific type that understands prometheus
|
||||
// config
|
||||
}
|
||||
|
||||
struct PrometheusRule {
|
||||
definition: String, // Not a string but an actual prometheus rule config
|
||||
}
|
||||
|
||||
struct PrometheusScrapeTarget {
|
||||
definition: String, // Not a string but an actual prometheus scraping config
|
||||
}
|
||||
|
||||
pub struct PrometheusMonitoringScore {
|
||||
alert_receivers: Vec<Box<dyn PrometheusReceiver>>,
|
||||
alert_rules: Vec<Box<PrometheusRule>>,
|
||||
scrape_targets: Vec<Box<PrometheusScrapeTarget>>,
|
||||
}
|
||||
|
||||
pub struct PrometheusMonitoringInterpret {}
|
||||
|
||||
#[async_trait]
|
||||
impl<T: Topology + PrometheusCapability> Interpret<T> for PrometheusMonitoringInterpret {
|
||||
async fn execute(
|
||||
&self,
|
||||
inventory: &Inventory,
|
||||
topology: &T,
|
||||
) -> Result<Outcome, InterpretError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_name(&self) -> InterpretName {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_version(&self) -> Version {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_status(&self) -> InterpretStatus {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn get_children(&self) -> Vec<Id> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub trait PrometheusCapability {
|
||||
fn install_alert_receivers(&self, receivers: Vec<Box<dyn PrometheusReceiver>>);
|
||||
fn install_alert_rules(&self, rules: Vec<Box<PrometheusRule>>);
|
||||
fn install_scrape_targets(&self, receivers: Vec<Box<PrometheusScrapeTarget>>);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct MonitoringAlertingScore<M: MonitoringSystem> {
|
||||
alert_receivers: Vec<Box<dyn AlertReceiver<M>>>,
|
||||
alert_rules: Vec<Box<dyn AlertRules<M>>>,
|
||||
monitoring_targets: Vec<Box<dyn MonitoringTarget<M>>>,
|
||||
}
|
||||
|
||||
impl<T: Topology + Monitor> Score<T> for MonitoringAlertingScore {
|
||||
fn create_interpret(&self) -> Box<dyn Interpret<T>> {
|
||||
Box::new(MonitoringAlertingInterpret {
|
||||
score: self.clone(),
|
||||
@ -65,3 +127,4 @@ impl<T: Topology + HelmCommand + Monitor> Interpret<T> for MonitoringAlertingInt
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user