-
Notifications
You must be signed in to change notification settings - Fork 997
fix: Enhance incident query to include alert enrichment for status #5062
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
fix: Enhance incident query to include alert enrichment for status #5062
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ 1 Skipped Deployment
|
β¦chment extraction
β¦reflected-in-the-incident-view
β¦uction for alert searches based on timeframe
β¦n-the-incident-view' of https://github.com/keephq/keep into 5049-Status-changes-for-an-incident-are-not-reflected-in-the-incident-view
β¦n-the-incident-view' of https://github.com/keephq/keep into 5049-Status-changes-for-an-incident-are-not-reflected-in-the-incident-view
β¦reflected-in-the-incident-view Signed-off-by: Ihor Panasiuk <igorskynet13@gmail.com>
Signed-off-by: Ihor Panasiuk <igorskynet13@gmail.com>
β¦ts_by_cel function
β¦n-the-incident-view' of https://github.com/keephq/keep into 5049-Status-changes-for-an-incident-are-not-reflected-in-the-incident-view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Invalid Join Condition Causes Enrichment Failure
The outerjoin
with incident_enrichment
(an alias for AlertEnrichment
) is flawed: its join condition cast(col(Incident.id), String) == foreign(incident_enrichment.alert_fingerprint)
incorrectly attempts to match Incident.id
(a UUID) with alert_fingerprint
(an alert hash), which are unrelated identifiers, preventing incident enrichment data retrieval. The foreign()
function is also misused here, as it's intended for SQLAlchemy relationship definitions. Additionally, this incident_enrichment
join is unconditionally added to all queries built by __build_base_incident_query
, causing unnecessary performance overhead for queries that do not require enrichment data.
keep/api/core/incidents.py#L256-L264
keep/keep/api/core/incidents.py
Lines 256 to 264 in 2406a60
sql_query = sql_query.outerjoin( | |
incident_enrichment, | |
and_( | |
Incident.tenant_id == incident_enrichment.tenant_id, | |
cast(col(Incident.id), String) | |
== foreign(incident_enrichment.alert_fingerprint), | |
), | |
) |
Was this report helpful? Give feedback by reacting with π or π
Closes #5049
π Description
β Checks
βΉ Additional Information