Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: timeline status change by API is automatic #1833

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
4 changes: 3 additions & 1 deletion keep/api/models/db/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class Incident(SQLModel, table=True):
id: UUID = Field(default_factory=uuid4, primary_key=True)
tenant_id: str = Field(foreign_key="tenant.id")
tenant: Tenant = Relationship()

user_generated_name: str | None
ai_generated_name: str | None

Expand Down Expand Up @@ -217,9 +217,11 @@ class AlertActionType(enum.Enum):
ACKNOWLEDGE = "alert acknowledged"
# the alert was resolved
AUTOMATIC_RESOLVE = "alert automatically resolved"
API_AUTOMATIC_RESOLVE = "alert automatically resolved by API"
# the alert was resolved manually
MANUAL_RESOLVE = "alert manually resolved"
MANUAL_STATUS_CHANGE = "alert status manually changed"
API_STATUS_CHANGE = "alert status changed by API"
STATUS_UNENRICH = "alert status undone"
# the alert was escalated
WORKFLOW_ENRICH = "alert enriched by workflow"
Expand Down
13 changes: 11 additions & 2 deletions keep/api/routes/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from fastapi.responses import JSONResponse
from pusher import Pusher


from keep.api.arq_pool import get_pool
from keep.api.bl.enrichments_bl import EnrichmentsBl
from keep.api.core.config import config
Expand Down Expand Up @@ -427,13 +426,23 @@ def enrich_alert(
try:
enrichement_bl = EnrichmentsBl(tenant_id)
# Shahar: TODO, change to the specific action type, good enough for now
if "status" in enrich_data.enrichments:
if (
"status" in enrich_data.enrichments
and authenticated_entity.api_key_name is None
):
action_type = (
AlertActionType.MANUAL_RESOLVE
if enrich_data.enrichments["status"] == "resolved"
else AlertActionType.MANUAL_STATUS_CHANGE
)
action_description = f"Alert status was changed to {enrich_data.enrichments['status']} by {authenticated_entity.email}"
elif "status" in enrich_data.enrichments and authenticated_entity.api_key_name:
action_type = (
AlertActionType.API_AUTOMATIC_RESOLVE
if enrich_data.enrichments["status"] == "resolved"
else AlertActionType.API_STATUS_CHANGE
)
action_description = f"Alert status was changed to {enrich_data.enrichments['status']} by API `{authenticated_entity.api_key_name}`"
elif "note" in enrich_data.enrichments and enrich_data.enrichments["note"]:
action_type = AlertActionType.COMMENT
action_description = f"Comment added by {authenticated_entity.email} - {enrich_data.enrichments['note']}"
Expand Down
Loading