-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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] [Detections] Combine multiple timestamp searches into single request #96078
Conversation
241b508
to
2935b34
Compare
// @ts-expect-error | ||
format: 'strict_date_optional_time', |
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.
typscript complains that the format
field is not applicable to the @timestamp
field. I think the type is wrong.
Pinging @elastic/security-solution (Team: SecuritySolution) |
Pinging @elastic/security-detections-response (Team:Detections and Resp) |
@elasticmachine merge upstream |
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! Good integration test coverage 👍
x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_events_query.test.ts
Outdated
Show resolved
Hide resolved
x-pack/test/detection_engine_api_integration/security_and_spaces/tests/generating_signals.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/signals/build_events_query.ts
Outdated
Show resolved
Hide resolved
x-pack/plugins/security_solution/server/lib/detection_engine/signals/utils.ts
Outdated
Show resolved
Hide resolved
…te signals when timestamp override is present in rule
…rch after functionality of detection rules
…filter was hardcoded to event.ingested :yikes:
…egration test, fixes logic for possibility of receving a null value in sort ids, removes unused utility function for checking valid sort ids
df74b28
to
d29c16f
Compare
…as failing because we moved the logic for checking that out of the build search query function and up into the big loop. So I moved that unit test into the search after bulk create test file.
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: cc @dhurley14 |
…into single request (elastic#96078) * merge multiple timestamp queries into one single search * fix types and unit tests * remove unused code for sending secondary search * removes unused excludeDocsWithTimestampOverride * adds integration tests to cover cases that should / should not generate signals when timestamp override is present in rule * adds integration test to ensure unmapped sort fields do not break search after functionality of detection rules * Need to figure out why moving the tests around fixed them... * updates tests with new es archive data and fixes bug where exclusion filter was hardcoded to event.ingested :yikes: * remove dead commented out code * fixes typo in test file, removes redundant delete signals call in integration test, fixes logic for possibility of receving a null value in sort ids, removes unused utility function for checking valid sort ids * a unit test for checking if an empty string of a sort id is present was failing because we moved the logic for checking that out of the build search query function and up into the big loop. So I moved that unit test into the search after bulk create test file. * fix types * removes isEmpty since it doesn't check for empty strings
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
…into single request (#96078) (#97722) * merge multiple timestamp queries into one single search * fix types and unit tests * remove unused code for sending secondary search * removes unused excludeDocsWithTimestampOverride * adds integration tests to cover cases that should / should not generate signals when timestamp override is present in rule * adds integration test to ensure unmapped sort fields do not break search after functionality of detection rules * Need to figure out why moving the tests around fixed them... * updates tests with new es archive data and fixes bug where exclusion filter was hardcoded to event.ingested :yikes: * remove dead commented out code * fixes typo in test file, removes redundant delete signals call in integration test, fixes logic for possibility of receving a null value in sort ids, removes unused utility function for checking valid sort ids * a unit test for checking if an empty string of a sort id is present was failing because we moved the logic for checking that out of the build search query function and up into the big loop. So I moved that unit test into the search after bulk create test file. * fix types * removes isEmpty since it doesn't check for empty strings Co-authored-by: Devin W. Hurley <devin.hurley@elastic.co>
Summary
Ref: #93550
We've been sending two separate queries when a timestamp override is provided to a rule definition in order to ensure we are also querying data that might have been sent over but is missing that timestamp override field for some reason.
The proposed change in this PR merges the logic of these two queries into one single search.
Added a few integration tests which should cover all cases but please take a look at those and point out any missing cases that should be covered.
Test data
Rule Query
After posting the above documents and executing the query in the search profiler in dev tools we can see that the query is behaving as we expect.
Screenshot
Checklist
Delete any items that are not applicable to this PR.
For maintainers