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

[Security Solution][Detection Engine] adds alert suppression to ES|QL rule type #180927

Merged
merged 77 commits into from
May 20, 2024

Conversation

vitaliidm
Copy link
Contributor

@vitaliidm vitaliidm commented Apr 16, 2024

Summary

Demo

  1. run esql rule w/o suppression
  2. run esql rule w/ suppression per rule execution. Since ES|QL query is aggregating, no alerts suppressed on already agrregated field host.ip
  3. run suppression on interval 20m
  4. run suppression for custom ES|QL field which is the same as host.ip, hence same results
  5. run suppression on interval 100m
_esql.suppression.mov

Limitations

Since suppressed alerts deduplication relies on alert timestamps, sorting of results other than @timestamp asc in ES|QL query may impact on number of suppressed alerts, when number of possible alerts more than max_signals.
This affects only non-aggregating queries, since suppression boundaries for these alerts set as rule execution time

Checklist

@vitaliidm vitaliidm added Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detection Engine Security Solution Detection Engine Area v8.15.0 labels Apr 16, 2024
@vitaliidm vitaliidm self-assigned this Apr 16, 2024
vitaliidm and others added 24 commits April 16, 2024 15:09
# Conflicts:
#	x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/use_experimental_feature_fields_transform.ts
#	x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_alert_suppression.test.tsx
#	x-pack/plugins/security_solution/public/detection_engine/rule_management/logic/use_alert_suppression.tsx
#	x-pack/test/security_solution_cypress/config.ts
…creation/logic/esql_validator.ts

Co-authored-by: Nikita Indik <[email protected]>
@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🎉 All tests passed! - kibana-flaky-test-suite-runner#6011

[✅] Security Solution Detection Engine - Cypress: 100/100 tests passed.
[✅] [Serverless] Security Solution Detection Engine - Cypress: 100/100 tests passed.

see run history

@vitaliidm vitaliidm requested a review from nikitaindik May 16, 2024 16:02
@vitaliidm vitaliidm requested a review from a team as a code owner May 17, 2024 11:56
vitaliidm added 8 commits May 17, 2024 13:04
# Conflicts:
#	x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/hooks/use_esql_index.ts
#	x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_creation/helpers.ts
#	x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/pages/rule_editing/index.tsx
@kibanamachine
Copy link
Contributor

Flaky Test Runner Stats

🟠 Some tests failed. - kibana-flaky-test-suite-runner#6029

[❌] Security Solution Detection Engine - Cypress: 74/100 tests passed.
[✅] [Serverless] Security Solution Detection Engine - Cypress: 100/100 tests passed.

see run history

Copy link
Contributor

@PhilippeOberti PhilippeOberti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

desk tested and code LGTM for the Threat Hunting Investigations team!

@@ -337,6 +337,7 @@ describe('Detection rules, Prebuilt Rules Installation and Update workflow', ()
type: 'esql',
language: 'esql',
query: 'FROM .alerts-security.alerts-default | STATS count = COUNT(@timestamp) BY @timestamp',
alert_suppression: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not pass a mock alert_suppression object here and then check that it's rendered like we do for custom query rules?

Also, I think we need to add alert suppression properties in the test plan under "ESQL" here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added in 8702a48

@nikitaindik
Copy link
Contributor

Encountered a weird rule preview behaviour while doing local testing. Sometimes rule preview displayed different alerts for me after clicking "Refresh". I made a screen recording once it started happening, but I couldn't reproduce it. Not sure if it's a bug and if it's related to rule suppression or not. Perhaps the screen recording might give @vitaliidm a hint on what might be going on.

rule_preview.mov

Copy link
Contributor

@nikitaindik nikitaindik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the code with focus on the Rule Management owned files. The changes LGTM. Left a couple comments.

@vitaliidm
Copy link
Contributor Author

Encountered a weird rule preview behaviour while doing local testing. Sometimes rule preview displayed different alerts for me after clicking "Refresh". I made a screen recording once it started happening, but I couldn't reproduce it. Not sure if it's a bug and if it's related to rule suppression or not. Perhaps the screen recording might give @vitaliidm a hint on what might be going on.

Not enough information to figure out what's going on here. I wasn't able to reproduce
I suspect it might be related to how preview runs multiple rule executions.
Would need additional info this one:

  • What's the rule configured schedule? Exported rule would be helpful.
  • HAR file would be helpful, would allow to see what response in preview request + generated alerts
  • Very suspicious, alerts genereated w/o original timestamp. I don't think I see that before.
  • Anything in Kibana logs?
  • What's the data you have in that index? Are there events w/o timestamp? Data coming from agent? Or just indexed manually and can be reproduced easily

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
securitySolution 15.1MB 15.1MB +555.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
securitySolution 83.5KB 83.5KB +45.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @vitaliidm

@vitaliidm vitaliidm merged commit 6e6b99c into elastic:main May 20, 2024
36 checks passed
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:feature Makes this part of the condensed release notes Team:Detection Engine Security Solution Detection Engine Area Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v8.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants