diff --git a/pyproject.toml b/pyproject.toml index 0b0cf64..2523f04 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ ignore_missing_imports = true [tool.poetry] name = "pyth-observer" -version = "0.3.2" +version = "0.3.3" description = "Alerts and stuff" authors = [] readme = "README.md" diff --git a/pyth_observer/dispatch.py b/pyth_observer/dispatch.py index d34036c..de5fb73 100644 --- a/pyth_observer/dispatch.py +++ b/pyth_observer/dispatch.py @@ -197,13 +197,16 @@ async def process_zenduty_events(self, current_time): to_remove.append(identifier) # Raise alert if failed > $threshold times within the last 5m window # or if already alerted and not yet resolved. - # Re-alert every 5 minutes but not more often. + # Re-alert at the start of each hour but not more often. elif ( info["failures"] >= alert_threshold or (info["sent"] and not resolved) ) and ( - not info.get("last_alert") - or current_time - datetime.fromisoformat(info["last_alert"]) - > timedelta(minutes=5) + not info.get("last_alert") # First alert - send immediately + or ( # Subsequent alerts - send at the start of each hour + current_time - datetime.fromisoformat(info["last_alert"]) + > timedelta(minutes=5) + and current_time.minute == 0 # Only alert at the start of each hour + ) ): logger.debug(f"Raising Zenduty alert {identifier}") self.open_alerts[identifier]["sent"] = True