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

[Search]Add EQL search strategy #78645

Merged
merged 12 commits into from
Oct 5, 2020
Merged

Conversation

rylnd
Copy link
Contributor

@rylnd rylnd commented Sep 28, 2020

Summary

The immediate need for this strategy for 7.10 is security_solution and its EQL detection rules. Since EQL is an x-pack feature, this strategy lives in the data_enhanced plugin.

While EQL does not return partial results, I plumbed through as much async functionality as possible (get, search, delete) using the other search strategies as a guide.

Outstanding questions:

  1. Are there any default configuration that that I missed?
    • timeout from config do not appear to be supported
    • max_concurrent_shard_requests and track_total_hits do not appear to be supported
    • I believe that I could place some config into querystring on options but it's unclear whether I need to do that
  2. Should this strategy exist in dev docs? I didn't find an analogous example for the existing enhanced search strategy.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

Since EQL is an x-pack feature, this strategy will live in the
x-pack plugin data_enhanced.
@rylnd rylnd added Feature:Search Querying infrastructure in Kibana v8.0.0 Team:AppArch v7.10.0 labels Sep 28, 2020
@rylnd rylnd requested a review from lizozom September 28, 2020 16:41
@rylnd rylnd self-assigned this Sep 28, 2020
@rylnd rylnd marked this pull request as ready for review September 28, 2020 19:01
@rylnd rylnd requested a review from a team as a code owner September 28, 2020 19:01
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-arch (Team:AppArch)

* Ensures that the same variable is not used for both test setup and
  test assertions
* Ensures that mocks are reinstantiated on every test
x-pack/plugins/data_enhanced/common/index.ts Outdated Show resolved Hide resolved
const eqlClient = context.core.elasticsearch.client.asCurrentUser.eql;
const uiSettingsClient = await context.core.uiSettings.client;
const asyncOptions = {
waitForCompletionTimeout: '100ms', // Wait up to 100ms for the response to return
Copy link
Contributor

Choose a reason for hiding this comment

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

These are needed only if the EQL endpint supports async search

Copy link
Contributor

Choose a reason for hiding this comment

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

@rylnd is this strategy a copy of the DSL search strategy, just with a different endpoint?
If so, lets think how we can reuse the code. I wouldn't want to maintain this logic twice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lizozom I've tried to keep it as similar as possible but there's plenty of deviation. I'll see if I can't extract some of the shared logic to some helpers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@lizozom I moved a few things to shared helpers: async options (9a61749) and our shimming of TransportRequestPromise (10b6979).

Please let me know if this is acceptable, or whether you had other changes in mind.

@rylnd
Copy link
Contributor Author

rylnd commented Sep 30, 2020

@lizozom I believe this is ready for another 👀 ! I do have a few outstanding questions in the PR description, as well, if you could take a look.

We export a few new helper functions.

export const eqlSearchStrategyProvider = (
logger: Logger
): ISearchStrategy<EqlSearchStrategyRequest, EqlSearchStrategyResponse> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

@rylnd I still suspect the two strategies are identical, except for the endpoint being used.
Don't you think we could do with adding a parameter to the normal strategy and using that one?

Lets talk about this.

@rylnd
Copy link
Contributor Author

rylnd commented Oct 5, 2020

@elasticmachine merge upstream

Copy link
Contributor

@lizozom lizozom left a comment

Choose a reason for hiding this comment

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

Looks good.
We'll extract common code as we go 👍

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

distributable file count

id before after diff
default 47107 47109 +2
oss 28597 28598 +1

page load bundle size

id before after diff
dataEnhanced 34.3KB 34.4KB +30.0B

History

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

@rylnd rylnd merged commit 951034c into elastic:master Oct 5, 2020
rylnd added a commit to rylnd/kibana that referenced this pull request Oct 5, 2020
* Add EQL search strategy

Since EQL is an x-pack feature, this strategy will live in the
x-pack plugin data_enhanced.

* Refactor our test setup to minimize shared state

* Ensures that the same variable is not used for both test setup and
  test assertions
* Ensures that mocks are reinstantiated on every test

* Use explicit top-level exports

* Move async search options to a helper function

* Move our workaround to a helper function

This was repeated in five places, time to consolidate.

* Commit documentation changes

We export a few new helper functions.

* Mark our internal methods as such

Updates documentation accordingly.

Co-authored-by: Kibana Machine <[email protected]>
rylnd added a commit that referenced this pull request Oct 5, 2020
* Add EQL search strategy

Since EQL is an x-pack feature, this strategy will live in the
x-pack plugin data_enhanced.

* Refactor our test setup to minimize shared state

* Ensures that the same variable is not used for both test setup and
  test assertions
* Ensures that mocks are reinstantiated on every test

* Use explicit top-level exports

* Move async search options to a helper function

* Move our workaround to a helper function

This was repeated in five places, time to consolidate.

* Commit documentation changes

We export a few new helper functions.

* Mark our internal methods as such

Updates documentation accordingly.

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants