Skip to content

Commit 4cf963b

Browse files
fix: Skip instance-level enrichment for elastic. Ensure enrichments are applied conditionally (#4645)
1 parent 0462580 commit 4cf963b

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

keep/api/bl/enrichments_bl.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,8 @@ def disposable_enrich_entity(
716716
alert_id = UUIDType(binary=False).process_bind_param(
717717
last_alert.alert_id, self.db_session.bind.dialect
718718
)
719+
# For elastic we do not save instance-level enrichments
720+
common_kwargs["should_exist"] = False
719721
self.enrich_entity(fingerprint=alert_id, audit_enabled=False, **common_kwargs)
720722

721723
def enrich_entity(

keep/providers/base/base_provider.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,19 +287,21 @@ def _enrich(self, enrichments, results, audit_enabled=True):
287287
"audit_enabled": audit_enabled,
288288
}
289289

290-
# enrich the alert with _enrichments
291-
enrichments_bl.enrich_entity(
292-
enrichments=_enrichments,
293-
action_description=f"Workflow enriched the alert with {enrichment_string}",
294-
**common_kwargs,
295-
)
290+
if _enrichments:
291+
# enrich the alert with _enrichments
292+
enrichments_bl.enrich_entity(
293+
enrichments=_enrichments,
294+
action_description=f"Workflow enriched the alert with {enrichment_string}",
295+
**common_kwargs,
296+
)
296297

297-
# enrich with disposable enrichments
298-
enrichments_bl.disposable_enrich_entity(
299-
enrichments=disposable_enrichments,
300-
action_description=f"Workflow enriched the alert with {disposable_enrichment_string}",
301-
**common_kwargs,
302-
)
298+
if disposable_enrichments:
299+
# enrich with disposable enrichments
300+
enrichments_bl.disposable_enrich_entity(
301+
enrichments=disposable_enrichments,
302+
action_description=f"Workflow enriched the alert with {disposable_enrichment_string}",
303+
**common_kwargs,
304+
)
303305

304306
should_check_incidents_resolution = (
305307
_enrichments.get("status", None) == "resolved"

0 commit comments

Comments
 (0)