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] [Detections] Multiple timestamp fields #86368

Merged
merged 11 commits into from
Dec 24, 2020

Conversation

dhurley14
Copy link
Contributor

@dhurley14 dhurley14 commented Dec 17, 2020

Summary

Resolves #75382

If the timestamp override field is missing for a given index pattern, utilize a secondary sort field of @timestamp to perform the search_after and sort on.

This will also set a failure status for rules and log the failure to our rule status SO with the concrete index name and the timestamp field missing from that index. My plan is to get this reviewed then incorporate the partial failure status at a later date as that piece is not mission-critical at the moment.

failing_rules_missing_timestamps

Testing:

Using the following indices

Indices

POST myfakeindex-1/_doc
{
  "message": "hello world 1"
}

POST myfakeindex-2/_doc
{
  "message": "hello world 2",
  "event": {
    "ingested": "2020-12-14T22:31:01.726Z"
  }
}

POST myfakeindex-3/_doc
{
  "message": "hello world 3",
  "@timestamp": "2020-12-14T22:31:01.726Z"
}

and a rule that searched *:* against the index pattern myfa* which matches all three indices above, we are able to search and produce signals against myfakeindex-2 and myfakeindex-3 thus the partial failure where we cannot search against myfakeindex-1 because it is missing both the timestamp override and the default @timestamp field from its mapping.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@dhurley14 dhurley14 force-pushed the timestamp-override-queries branch 2 times, most recently from 321b10d to 4e780d8 Compare December 18, 2020 22:01
@dhurley14 dhurley14 force-pushed the timestamp-override-queries branch from cef7d48 to e14334a Compare December 21, 2020 00:53
@dhurley14 dhurley14 self-assigned this Dec 21, 2020
@dhurley14 dhurley14 added release_note:fix review Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. Team:Detections and Resp Security Detection Response Team v7.11.0 v7.12.0 v8.0.0 labels Dec 21, 2020
@dhurley14 dhurley14 marked this pull request as ready for review December 21, 2020 00:55
@dhurley14 dhurley14 requested review from a team as code owners December 21, 2020 00:55
@dhurley14 dhurley14 force-pushed the timestamp-override-queries branch from bd3031c to 3c1a9ed Compare December 22, 2020 21:29
@dhurley14 dhurley14 force-pushed the timestamp-override-queries branch from 3c1a9ed to 14f9c77 Compare December 23, 2020 22:14
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Distributable file count

id before after diff
default 47260 48020 +760

History

  • 💚 Build #96087 succeeded 3c1a9ed7fb5d6ac00b62c44fe66e1df183b530b2
  • 💔 Build #96063 failed bd3031c7093bad8b5a9ee627034d82a6a3b801a6
  • 💚 Build #95904 succeeded a0438485f830e9a0dece0e72e5c8aa1bef56ab80
  • 💚 Build #95883 succeeded f0759b75f3e357e8e93f515d345d2e2385e42add
  • 💚 Build #95662 succeeded e14334a6773976b978103129efbf9f2c8b435c5f

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

@dhurley14 dhurley14 merged commit 113634a into elastic:master Dec 24, 2020
@dhurley14 dhurley14 deleted the timestamp-override-queries branch December 24, 2020 02:45
dhurley14 added a commit to dhurley14/kibana that referenced this pull request Dec 24, 2020
…6368)

* query timestamp override and default @timestamp field, adds functional test for this

* fix logic for when to filter out timestamp override documents

* update the total hits field of the search result if we find hits within the secondary search. Without updating the total hits field, we could be finding events but not indexing them based on the bulk create logic

* update integration test, updates logic for performing second search and excluding documents with timestamp override field

* cleanup comments, remove commented out console logs, fix logic to break out of loop during secondary search after

* default param to 'succeeded'

* remove commented out code

* always perform a secondary search when timestamp override field is present

* perf improvement and fix bug where sortIds were being mixed between search after calls

* set sortIds to undefined when not present on search result

* exit loop and prevent extraneous searches from occurring if we exhaust sort ids
@kibanamachine kibanamachine added the backport missing Added to PRs automatically when the are determined to be missing a backport. label Dec 28, 2020
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

5 similar comments
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

dhurley14 added a commit to dhurley14/kibana that referenced this pull request Jan 4, 2021
…6368)

* query timestamp override and default @timestamp field, adds functional test for this

* fix logic for when to filter out timestamp override documents

* update the total hits field of the search result if we find hits within the secondary search. Without updating the total hits field, we could be finding events but not indexing them based on the bulk create logic

* update integration test, updates logic for performing second search and excluding documents with timestamp override field

* cleanup comments, remove commented out console logs, fix logic to break out of loop during secondary search after

* default param to 'succeeded'

* remove commented out code

* always perform a secondary search when timestamp override field is present

* perf improvement and fix bug where sortIds were being mixed between search after calls

* set sortIds to undefined when not present on search result

* exit loop and prevent extraneous searches from occurring if we exhaust sort ids
dhurley14 added a commit to dhurley14/kibana that referenced this pull request Jan 4, 2021
…6368)

* query timestamp override and default @timestamp field, adds functional test for this

* fix logic for when to filter out timestamp override documents

* update the total hits field of the search result if we find hits within the secondary search. Without updating the total hits field, we could be finding events but not indexing them based on the bulk create logic

* update integration test, updates logic for performing second search and excluding documents with timestamp override field

* cleanup comments, remove commented out console logs, fix logic to break out of loop during secondary search after

* default param to 'succeeded'

* remove commented out code

* always perform a secondary search when timestamp override field is present

* perf improvement and fix bug where sortIds were being mixed between search after calls

* set sortIds to undefined when not present on search result

* exit loop and prevent extraneous searches from occurring if we exhaust sort ids
@kibanamachine
Copy link
Contributor

Looks like this PR has backport PRs but they still haven't been merged. Please merge them ASAP to keep the branches relatively in sync.

dhurley14 added a commit that referenced this pull request Jan 5, 2021
) (#86926)

* [Security Solution] [Detections] Multiple timestamp fields (#86368)

* query timestamp override and default @timestamp field, adds functional test for this

* fix logic for when to filter out timestamp override documents

* update the total hits field of the search result if we find hits within the secondary search. Without updating the total hits field, we could be finding events but not indexing them based on the bulk create logic

* update integration test, updates logic for performing second search and excluding documents with timestamp override field

* cleanup comments, remove commented out console logs, fix logic to break out of loop during secondary search after

* default param to 'succeeded'

* remove commented out code

* always perform a secondary search when timestamp override field is present

* perf improvement and fix bug where sortIds were being mixed between search after calls

* set sortIds to undefined when not present on search result

* exit loop and prevent extraneous searches from occurring if we exhaust sort ids

* skips test that was skipped in 8.0 / master
dhurley14 added a commit that referenced this pull request Jan 5, 2021
…6368) (#86927)

* [Security Solution] [Detections] Multiple timestamp fields (#86368)

* query timestamp override and default @timestamp field, adds functional test for this

* fix logic for when to filter out timestamp override documents

* update the total hits field of the search result if we find hits within the secondary search. Without updating the total hits field, we could be finding events but not indexing them based on the bulk create logic

* update integration test, updates logic for performing second search and excluding documents with timestamp override field

* cleanup comments, remove commented out console logs, fix logic to break out of loop during secondary search after

* default param to 'succeeded'

* remove commented out code

* always perform a secondary search when timestamp override field is present

* perf improvement and fix bug where sortIds were being mixed between search after calls

* set sortIds to undefined when not present on search result

* exit loop and prevent extraneous searches from occurring if we exhaust sort ids

* skips test that was skipped in 8.0 / master
@kibanamachine kibanamachine removed the backport missing Added to PRs automatically when the are determined to be missing a backport. label Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release_note:fix review Team:Detections and Resp Security Detection Response Team Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v7.11.0 v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Security Solution][Detections] Support querying with multiple timestamps in Detection Rules
4 participants