feat: scrape targets to be able to get snmp alerts from machines to prometheus #171

Merged
wjro merged 3 commits from feat/scrape_target into master 2025-10-22 15:33:25 +00:00
2 changed files with 7 additions and 5 deletions
Showing only changes of commit cb66b7592e - Show all commits

View File

@ -21,7 +21,7 @@ pub struct AlertingInterpret<S: AlertSender> {
pub sender: S,
pub receivers: Vec<Box<dyn AlertReceiver<S>>>,
pub rules: Vec<Box<dyn AlertRule<S>>>,
pub scrape_target: Vec<Box<dyn ScrapeTarget<S>>>,
pub scrape_targets: Option<Vec<Box<dyn ScrapeTarget<S>>>>,
letian marked this conversation as resolved Outdated

Should it be scrape_targets? as it's a vector

Should it be `scrape_targets`? as it's a vector
}
#[async_trait]
@ -39,9 +39,11 @@ impl<S: AlertSender + Installable<T>, T: Topology> Interpret<T> for AlertingInte
debug!("installing rule: {:#?}", rule);
rule.install(&self.sender).await?;
}
for target in self.scrape_target.iter() {
debug!("installing scrape_target: {:#?}", target);
target.install(&self.sender).await?;
if let Some(targets) = &self.scrape_targets {
for target in targets.iter() {
debug!("installing scrape_target: {:#?}", target);
target.install(&self.sender).await?;
}
}
self.sender.ensure_installed(inventory, topology).await?;
Ok(Outcome::success(format!(

View File

@ -31,7 +31,7 @@ impl<T: Topology + HelmCommand + TenantManager> Score<T> for HelmPrometheusAlert
sender: KubePrometheus { config },
receivers: self.receivers.clone(),
rules: self.rules.clone(),
scrape_target: vec![],
scrape_targets: None,
letian marked this conversation as resolved Outdated

Should we actually configure something here? Because we pass an empty list it doesn't seem used.

Should we actually configure something here? Because we pass an empty list it doesn't seem used.
Outdated
Review

I will make this an Option<Vec> since it is not used in this score

I will make this an Option<Vec<ScrapeTarget>> since it is not used in this score
})
}
fn name(&self) -> String {