Skip to content

Commit 9ab8f71

Browse files
EQL: fix async missing events and re-enable the feature (elastic#97718)
1 parent 57d5fbd commit 9ab8f71

File tree

17 files changed

+672
-535
lines changed

17 files changed

+672
-535
lines changed

docs/changelog/97718.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 97718
2+
summary: Fix async missing events
3+
area: EQL
4+
type: bug
5+
issues:
6+
- 97644

server/src/main/java/org/elasticsearch/TransportVersion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,10 @@ private static TransportVersion registerTransportVersion(int id, String uniqueId
159159
// Introduced for stateless plugin
160160
public static final TransportVersion V_8_500_036 = registerTransportVersion(8_500_036, "3343c64f-d7ac-4f02-9262-3e1acfc56f89");
161161
public static final TransportVersion V_8_500_037 = registerTransportVersion(8_500_037, "d76a4f22-8878-43e0-acfa-15e452195fa7");
162+
public static final TransportVersion V_8_500_038 = registerTransportVersion(8_500_038, "9ef93580-feae-409f-9989-b49e411ca7a9");
162163

163164
private static class CurrentHolder {
164-
private static final TransportVersion CURRENT = findCurrent(V_8_500_037);
165+
private static final TransportVersion CURRENT = findCurrent(V_8_500_038);
165166

166167
// finds the pluggable current version, or uses the given fallback
167168
private static TransportVersion findCurrent(TransportVersion fallback) {

x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/BaseEqlSpecTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,10 @@ private long[] extractIds(List<Map<String, Object>> events) {
244244
final long[] ids = new long[len];
245245
for (int i = 0; i < len; i++) {
246246
Map<String, Object> event = events.get(i);
247-
Map<String, Object> source = (Map<String, Object>) event.get("_source");
248-
if (source == null) {
247+
if (Boolean.TRUE.equals(event.get("missing"))) {
249248
ids[i] = -1;
250249
} else {
250+
Map<String, Object> source = (Map<String, Object>) event.get("_source");
251251
Object field = source.get(idField());
252252
ids[i] = ((Number) field).longValue();
253253
}

x-pack/plugin/eql/qa/common/src/main/java/org/elasticsearch/test/eql/DataLoader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public static void loadDatasetIntoEs(
107107
//
108108
// missing_events index
109109
//
110-
// load(client, TEST_MISSING_EVENTS_INDEX, null, null, p);
110+
load(client, TEST_MISSING_EVENTS_INDEX, null, null, p);
111111
load(client, TEST_SAMPLE_MULTI, null, null, p);
112112
}
113113

x-pack/plugin/eql/qa/rest/src/javaRestTest/java/org/elasticsearch/xpack/eql/EqlMissingEventsIT.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@
77

88
package org.elasticsearch.xpack.eql;
99

10-
import org.apache.lucene.tests.util.LuceneTestCase;
1110
import org.elasticsearch.test.eql.EqlMissingEventsSpecTestCase;
1211

1312
import java.util.List;
1413

15-
@LuceneTestCase.AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/97644")
1614
public class EqlMissingEventsIT extends EqlMissingEventsSpecTestCase {
1715

1816
public EqlMissingEventsIT(String query, String name, List<long[]> eventIds, String[] joinKeys, Integer size, Integer maxSamplesPerKey) {

x-pack/plugin/eql/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/eql/10_basic.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,7 @@ setup:
436436

437437
---
438438
"Sequence with missing events.":
439-
- skip:
440-
version: "all"
441-
reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/97644"
439+
442440
- do:
443441
eql.search:
444442
index: eql_test
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
setup:
3+
- do:
4+
indices.create:
5+
index: eql_test
6+
body:
7+
mappings:
8+
properties:
9+
"@timestamp":
10+
type: date
11+
event.category:
12+
type: keyword
13+
user:
14+
type: keyword
15+
16+
- do:
17+
bulk:
18+
refresh: true
19+
body:
20+
- index:
21+
_index: eql_test
22+
_id: "1"
23+
- event:
24+
- category: process
25+
"@timestamp": 2023-07-11T11:09:05.529Z
26+
user: foo
27+
- index:
28+
_index: eql_test
29+
_id: "2"
30+
- event:
31+
- category: process
32+
"@timestamp": 2023-07-11T11:09:06.529Z
33+
user: bar
34+
35+
---
36+
37+
"Execute async EQL with missing events":
38+
- do:
39+
eql.search:
40+
index: eql_test
41+
wait_for_completion_timeout: "0ms"
42+
keep_on_completion: true
43+
body:
44+
query: 'sequence with maxspan=24h [ process where true ] ![ process where true ]'
45+
46+
- is_true: id
47+
- set: {id: id}
48+
- gte: {took: 0}
49+
50+
- do:
51+
eql.get:
52+
id: $id
53+
wait_for_completion_timeout: "10s"
54+
55+
- match: {is_running: false}
56+
- match: {is_partial: false}
57+
- match: {timed_out: false}
58+
- match: {hits.total.value: 1}
59+
- match: {hits.total.relation: "eq"}
60+
- match: {hits.sequences.0.events.0._source.user: "bar"}
61+
- match: {hits.sequences.0.events.1.missing: true}

x-pack/plugin/eql/src/main/antlr/EqlBase.g4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ sequenceTerm
6666
;
6767

6868
subquery
69-
: LB eventFilter RB
69+
: (LB | MISSING_EVENT_OPEN) eventFilter RB
7070
;
7171

7272
eventQuery
@@ -212,6 +212,7 @@ LP: '(';
212212
RP: ')';
213213
PIPE: '|';
214214
OPTIONAL: '?';
215+
MISSING_EVENT_OPEN: '![';
215216

216217
fragment STRING_ESCAPE
217218
: '\\' [btnfr"'\\]

x-pack/plugin/eql/src/main/antlr/EqlBase.tokens

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ LP=40
4141
RP=41
4242
PIPE=42
4343
OPTIONAL=43
44-
STRING=44
45-
INTEGER_VALUE=45
46-
DECIMAL_VALUE=46
47-
IDENTIFIER=47
48-
QUOTED_IDENTIFIER=48
49-
TILDE_IDENTIFIER=49
50-
LINE_COMMENT=50
51-
BRACKETED_COMMENT=51
52-
WS=52
44+
MISSING_EVENT_OPEN=44
45+
STRING=45
46+
INTEGER_VALUE=46
47+
DECIMAL_VALUE=47
48+
IDENTIFIER=48
49+
QUOTED_IDENTIFIER=49
50+
TILDE_IDENTIFIER=50
51+
LINE_COMMENT=51
52+
BRACKETED_COMMENT=52
53+
WS=53
5354
'and'=1
5455
'any'=2
5556
'by'=3
@@ -93,3 +94,4 @@ WS=52
9394
')'=41
9495
'|'=42
9596
'?'=43
97+
'!['=44

x-pack/plugin/eql/src/main/antlr/EqlBaseLexer.tokens

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ LP=40
4141
RP=41
4242
PIPE=42
4343
OPTIONAL=43
44-
STRING=44
45-
INTEGER_VALUE=45
46-
DECIMAL_VALUE=46
47-
IDENTIFIER=47
48-
QUOTED_IDENTIFIER=48
49-
TILDE_IDENTIFIER=49
50-
LINE_COMMENT=50
51-
BRACKETED_COMMENT=51
52-
WS=52
44+
MISSING_EVENT_OPEN=44
45+
STRING=45
46+
INTEGER_VALUE=46
47+
DECIMAL_VALUE=47
48+
IDENTIFIER=48
49+
QUOTED_IDENTIFIER=49
50+
TILDE_IDENTIFIER=50
51+
LINE_COMMENT=51
52+
BRACKETED_COMMENT=52
53+
WS=53
5354
'and'=1
5455
'any'=2
5556
'by'=3
@@ -93,3 +94,4 @@ WS=52
9394
')'=41
9495
'|'=42
9596
'?'=43
97+
'!['=44

0 commit comments

Comments
 (0)