Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 7 additions & 4 deletions pyth_observer/dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading