Skip to content

Commit 87e262b

Browse files
committed
bugfix and alerts retry
1 parent ece7953 commit 87e262b

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

src/alerts/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ impl AlertConfig {
659659

660660
// validate condition config
661661
let agg1 = &self.aggregates.aggregate_config[0];
662-
let agg2 = &self.aggregates.aggregate_config[0];
662+
let agg2 = &self.aggregates.aggregate_config[1];
663663

664664
validate_condition_config(&agg1.conditions)?;
665665
validate_condition_config(&agg2.conditions)?;

src/sync.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,25 @@ pub async fn alert_runtime(mut rx: mpsc::Receiver<AlertTask>) -> Result<(), anyh
246246
let alert = alert.clone();
247247
let id = alert.id;
248248
let handle = tokio::spawn(async move {
249+
let mut retry_counter = 0;
250+
let mut sleep_duration = alert.get_eval_frequency();
249251
loop {
250252
match alerts_utils::evaluate_alert(&alert).await {
251-
Ok(_) => {}
253+
Ok(_) => {
254+
retry_counter = 0;
255+
}
252256
Err(err) => {
253-
error!("Error while evaluation- {err}");
254-
break;
257+
warn!("Error while evaluation- {}\nRetrying after sleeping for 1 minute", err);
258+
sleep_duration = 1;
259+
retry_counter += 1;
260+
261+
if retry_counter > 3 {
262+
error!("Alert with id {} failed to evaluate after 3 retries with err- {}", id, err);
263+
break;
264+
}
255265
}
256266
}
257-
tokio::time::sleep(Duration::from_secs(alert.get_eval_frequency() * 60))
258-
.await;
267+
tokio::time::sleep(Duration::from_secs(sleep_duration * 60)).await;
259268
}
260269
});
261270

0 commit comments

Comments
 (0)