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

EQL: make allow_no_indices true by default #63573

Merged
merged 3 commits into from
Oct 12, 2020
Merged

Conversation

astefan
Copy link
Contributor

@astefan astefan commented Oct 12, 2020

allow_no_indices is now true by default and, as before, can be set in the _eql request as a parameter. Irrespective of allow_no_indices value, throw verification_exception when there is no index validated from the provided patterns. If allow_no_indices is false and there is a pattern that results in a no index being returned, the Elasticsearch's mapping_exception is thrown.

Fixes #62986.

Irrespective of allow_no_indices value, throw VerificationException when
there is no index validated
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-ql (:Query Languages/EQL)

@elasticmachine elasticmachine added the Team:QL (Deprecated) Meta label for query languages team label Oct 12, 2020
Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

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

Left a minor comment but LGTM otherwise.

Comment on lines 23 to 28
// wrap a potential index_not_found_exception with a VerificationException (expected by client)
try {
esIndex = indices.get();
} catch (MappingException me) {
throw new VerificationException(Collections.singletonList(Failure.fail(plan, me.getMessage())));
}
Copy link
Member

Choose a reason for hiding this comment

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

Use indices.isValid instead to check if the index is valid and if it's not, call toString() on it which returns the message instead of the index name.
Potentially pass the listener in the method to call onFailure with the failure instead of throwing it.

@@ -100,7 +100,7 @@ public void analyzedPlan(LogicalPlan parsed, ActionListener<LogicalPlan> listene
listener.onFailure(new TaskCancelledException("cancelled"));
return;
}
indexResolver.resolveAsMergedMapping(indexWildcard, null, configuration.includeFrozen(), configuration.filter(),
indexResolver.resolveAsMergedMapping(indexWildcard, null, configuration.indicesOptions(), configuration.filter(),
Copy link
Member

Choose a reason for hiding this comment

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

👍

@rylnd
Copy link

rylnd commented Oct 12, 2020

While this looks to be the behavior that we want, I'm wondering whether allow_no_indices is the correct option, here. This was discussed previously in #62986 (comment) and I believe #63295 captures the logical conclusion of that discussion.

Again, this is a blocker for EQL detections so I'm happy with any solution, but I wanted to re-raise the question since it had been raised previously.

@costin
Copy link
Member

costin commented Oct 12, 2020

We think this solves it.In ES allow_no_indices is true by default while in ES it is not. The issue with index options is that they are applied per index not per request so:
GET auditbeat-*,foo*/_eql/search means auditbeat-* and foo* are checked in isolation: the former exists, the latter does not.
By using the default options, that is allow_no_indices to be true, ES will match auditbeat, ignore foo and then call us. Previously that did not happen since the index resolution was happening before EQL was triggered.
We still need to do validation in case of GET foo*/_eql/search as allow_no_indices is true and thus no mapping is found...
Hth,

@astefan astefan merged commit 5ec70e5 into elastic:master Oct 12, 2020
@astefan astefan deleted the 62986_fix branch October 12, 2020 20:02
astefan added a commit to astefan/elasticsearch that referenced this pull request Oct 12, 2020
* Allow all indices options variants
Irrespective of allow_no_indices value, throw VerificationException when
there is no index validated

(cherry picked from commit 5ec70e5)
astefan added a commit that referenced this pull request Oct 12, 2020
* Allow all indices options variants
Irrespective of allow_no_indices value, throw VerificationException when
there is no index validated

(cherry picked from commit 5ec70e5)
rylnd pushed a commit to rylnd/elasticsearch that referenced this pull request Oct 13, 2020
* Allow all indices options variants
Irrespective of allow_no_indices value, throw VerificationException when
there is no index validated
astefan added a commit that referenced this pull request Oct 14, 2020
* Allow all indices options variants
Irrespective of allow_no_indices value, throw VerificationException when
there is no index validated

Co-authored-by: Andrei Stefan <astefan@users.noreply.github.com>
rylnd added a commit to rylnd/kibana that referenced this pull request Nov 10, 2020
These were previously needed to work around an index resolution but, but
this has since been resolved upstream in elasticsearch via
elastic/elasticsearch#63573.
rylnd added a commit to elastic/kibana that referenced this pull request Nov 16, 2020
* Ensure that data is not lost when parsing EQL responses

The shared search utilities expect that response data exists in the
response's body field. However, in an EQL response this information also
exists as a sibling to the body field, and so we must normalize this data
into the body before we can leverage these utilities with EQL queries.

* Remove unused EQL parameters

These were previously needed to work around an index resolution but, but
this has since been resolved upstream in elasticsearch via
elastic/elasticsearch#63573.

* Allow custom test subj for Preview Histogram to propagate to DOM

Previously, custom preview histograms were passing a data-test-subj prop
to our general histogram, but the general histogram did not know/care
about this prop and it did not become a data property on the underlying
DOM element. While most of our tests leveraged enzyme, they could still
query by this react prop and everything worked as expected.

However, now that we want to exercise this behavior in cypress, we need
something to propagate to the DOM so that we can determine which
histogram has rendered, so the prop has been updated to be
`dataTestSubj`, which then becomes a data-test-subj on the histogram's
panel. Tests have been updated accordingly.

* Exercise Query Preview during EQL rule creation

* Asserts that the preview displays a histogram
* Asserts that no error toast is displayed

* Add integration tests around EQL sequence signal generation

* Clearer assertion

* Simplify test assertion

* Fix typings

These were updated on an upstream refactor.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
rylnd added a commit to elastic/kibana that referenced this pull request Nov 17, 2020
* Ensure that data is not lost when parsing EQL responses

The shared search utilities expect that response data exists in the
response's body field. However, in an EQL response this information also
exists as a sibling to the body field, and so we must normalize this data
into the body before we can leverage these utilities with EQL queries.

* Remove unused EQL parameters

These were previously needed to work around an index resolution but, but
this has since been resolved upstream in elasticsearch via
elastic/elasticsearch#63573.

* Allow custom test subj for Preview Histogram to propagate to DOM

Previously, custom preview histograms were passing a data-test-subj prop
to our general histogram, but the general histogram did not know/care
about this prop and it did not become a data property on the underlying
DOM element. While most of our tests leveraged enzyme, they could still
query by this react prop and everything worked as expected.

However, now that we want to exercise this behavior in cypress, we need
something to propagate to the DOM so that we can determine which
histogram has rendered, so the prop has been updated to be
`dataTestSubj`, which then becomes a data-test-subj on the histogram's
panel. Tests have been updated accordingly.

* Exercise Query Preview during EQL rule creation

* Asserts that the preview displays a histogram
* Asserts that no error toast is displayed

* Add integration tests around EQL sequence signal generation

* Clearer assertion

* Simplify test assertion

* Fix typings

These were updated on an upstream refactor.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
# Conflicts:
#	x-pack/plugins/security_solution/cypress/tasks/create_new_rule.ts
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.

EQL: allow_no_indices behavior
5 participants