Skip to content

Commit 31f650b

Browse files
committed
bugfix and alerts retry
1 parent ece7953 commit 31f650b

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
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: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,16 +246,23 @@ 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 {
251253
Ok(_) => {}
252254
Err(err) => {
253-
error!("Error while evaluation- {err}");
254-
break;
255+
warn!("Error while evaluation- {}\nRetrying after sleeping for 1 minute", err);
256+
sleep_duration = 1;
257+
retry_counter += 1;
258+
259+
if retry_counter > 3 {
260+
error!("Alert with id {} failed to evaluate after 3 retries with err- {}", id, err);
261+
break;
262+
}
255263
}
256264
}
257-
tokio::time::sleep(Duration::from_secs(alert.get_eval_frequency() * 60))
258-
.await;
265+
tokio::time::sleep(Duration::from_secs(sleep_duration * 60)).await;
259266
}
260267
});
261268

0 commit comments

Comments
 (0)