Skip to content

Commit de9fea4

Browse files
committed
fix: remove heartbeat alerts from Production environment when adding new heartbeat alerts to Heartbeat environment
1 parent 9c70e64 commit de9fea4

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

alertaclient/commands/cmd_heartbeats.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,20 @@ def cli(obj, alert, severity, timeout, purge):
106106
)
107107
break
108108
if not alert_exists:
109+
old_alerts = client.get_alerts(
110+
query=[
111+
('environment', 'Production'),
112+
('event', 'HeartbeatFail'),
113+
('event', 'HeartbeatSlow'),
114+
('event', 'HeartbeatOK'),
115+
('resource', b.origin)
116+
],
117+
page_size=len(heartbeats)
118+
)
119+
120+
for old_alert in old_alerts:
121+
client.delete_alert(old_alert.id)
122+
109123
client.send_alert(
110124
resource=b.origin,
111125
event=state['event'],

0 commit comments

Comments
 (0)