Skip to content

Commit

Permalink
feat: added event_id to alertDTO to utilize as unique identifier in w…
Browse files Browse the repository at this point in the history
…orkflows and rest
  • Loading branch information
pehlicd committed Apr 11, 2024
1 parent c410710 commit fbd3b18
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions keep/api/core/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,7 @@ def get_last_alerts(tenant_id, provider_id=None, limit=1000) -> list[Alert]:
alerts = []
for alert, startedAt in alerts_with_start:
alert.event["startedAt"] = str(startedAt)
alert.event["event_id"] = str(alert.id)
alerts.append(alert)

return alerts
Expand Down
6 changes: 4 additions & 2 deletions keep/api/routes/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@ def handle_formatted_events(
alert_hash=formatted_event.alert_hash,
)
session.add(alert)
formatted_event.event_id = alert.id
alert_dto = AlertDto(**alert.event)
session.flush()
session.refresh(alert)
formatted_event.event_id = str(alert.id)
alert_dto = AlertDto(**formatted_event.dict())

enrichments_bl = EnrichmentsBl(tenant_id, session)
# Mapping
Expand Down

0 comments on commit fbd3b18

Please sign in to comment.