Skip to content

Commit

Permalink
EQL: Change result_position default value from head to tail (#66387)
Browse files Browse the repository at this point in the history
By default, if no pipe is specified, EQL will return return matchings from the tail, end of the stream,  not the front. The results are returned in ascending order.
  • Loading branch information
costin authored Dec 17, 2020
1 parent 96555bf commit 2f50423
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class EqlSearchRequest implements Validatable, ToXContentObject {
private QueryBuilder filter = null;
private String timestampField = "@timestamp";
private String eventCategoryField = "event.category";
private String resultPosition = "head";
private String resultPosition = "tail";

private int size = 10;
private int fetchSize = 1000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public void testEqlRestUsage() throws IOException {
DataLoader.loadDatasetIntoEs(highLevelClient(), this::createParser);
}

String defaultPipe = "pipe_tail";
//
// random event queries
//
Expand All @@ -141,7 +142,7 @@ public void testEqlRestUsage() throws IOException {
runEql("sequence [process where serial_event_id == 1] [process where serial_event_id == 2]");
}
responseAsMap = getStats();
metricsToCheck = Set.of("sequence", "sequence_queries_two", "pipe_head");
metricsToCheck = Set.of("sequence", "sequence_queries_two", defaultPipe);
assertFeaturesMetrics(randomSequenceExecutions, responseAsMap, metricsToCheck);
assertFeaturesMetricsExcept(responseAsMap, metricsToCheck);
assertAllQueryMetrics(allTotalQueries, responseAsMap);
Expand Down Expand Up @@ -194,7 +195,7 @@ public void testEqlRestUsage() throws IOException {
" [process where opcode == 2] by user");
}
responseAsMap = getStats();
metricsToCheck = Set.of("sequence", "sequence_queries_three", "pipe_head", "join_keys_one", "sequence_maxspan");
metricsToCheck = Set.of("sequence", "sequence_queries_three", "join_keys_one", "sequence_maxspan", defaultPipe);
assertFeaturesMetrics(randomThreeQueriesSequences, responseAsMap, metricsToCheck);
assertFeaturesMetricsExcept(responseAsMap, metricsToCheck);
assertAllQueryMetrics(allTotalQueries, responseAsMap);
Expand Down Expand Up @@ -230,7 +231,7 @@ public void testEqlRestUsage() throws IOException {
" [process where opcode == 1]");
}
responseAsMap = getStats();
metricsToCheck = Set.of("sequence", "sequence_queries_two", "pipe_head", "join_keys_four");
metricsToCheck = Set.of("sequence", "sequence_queries_two", "join_keys_four", defaultPipe);
assertFeaturesMetrics(randomFourJoinKeysExecutions, responseAsMap, metricsToCheck);
assertFeaturesMetricsExcept(responseAsMap, metricsToCheck);
assertAllQueryMetrics(allTotalQueries, responseAsMap);
Expand All @@ -246,7 +247,7 @@ public void testEqlRestUsage() throws IOException {
" [process where opcode == 1]");
}
responseAsMap = getStats();
metricsToCheck = Set.of("sequence", "sequence_queries_two", "pipe_head", "join_keys_five_or_more");
metricsToCheck = Set.of("sequence", "sequence_queries_two", "join_keys_five_or_more", defaultPipe);
assertFeaturesMetrics(randomFiveJoinKeysExecutions, responseAsMap, metricsToCheck);
assertFeaturesMetricsExcept(responseAsMap, metricsToCheck);
assertAllQueryMetrics(allTotalQueries, responseAsMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public class EqlSearchRequest extends ActionRequest implements IndicesRequest.Re
private int size = RequestDefaults.SIZE;
private int fetchSize = RequestDefaults.FETCH_SIZE;
private String query;
private String resultPosition = "head";
private String resultPosition = "tail";

// Async settings
private TimeValue waitForCompletionTimeout = null;
Expand Down

0 comments on commit 2f50423

Please sign in to comment.