EQL: Introduce repeatable queries#75082
Conversation
Allow individual queries within a sequence to be repeated through a dedicated keyword without having physical duplication. sequence queryA repeat=2 queryB queryC repeat=3 queryD is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise.
astefan
left a comment
There was a problem hiding this comment.
Looks great.
Some unit tests need to be added for the new exceptions. And the scenarios where multiple repeats are used in the same sequence need clarification.
| query = ''' | ||
| sequence | ||
| [process where opcode == 1] by unique_pid, process_path | ||
| [file where opcode == 0] by unique_pid, process_path repeat=3 |
There was a problem hiding this comment.
How about the following scenario?
[file where opcode == 0] by unique_pid, process_path repeat=2
[file where opcode == 0] by unique_pid, process_path repeat=1
| if (numberOfQueries > 256) { | ||
| throw new ParsingException( | ||
| source(sequenceTermCtx), | ||
| "Sequence cannot contains more than 256 queries; found [{}]", |
There was a problem hiding this comment.
| "Sequence cannot contains more than 256 queries; found [{}]", | |
| "Sequence cannot contain more than 256 queries; found [{}]", |
| } | ||
|
|
||
| if (queries.size() < 2) { | ||
| throw new ParsingException(source, "A sequence requires a minimum of 2 queries, found [{}]", queries.size()); |
There was a problem hiding this comment.
| throw new ParsingException(source, "A sequence requires a minimum of 2 queries, found [{}]", queries.size()); | |
| throw new ParsingException(source, "A sequence requires a minimum of 2 queries, found [{}]", queries.size()); |
There was a problem hiding this comment.
Can you also test this new exception?
…table-queries Update EQL repeatable through runs option
astefan
left a comment
There was a problem hiding this comment.
LGTM. Left one minor comment.
| } | ||
| } | ||
|
|
||
| int runs = 1; |
There was a problem hiding this comment.
If this is limited to 100, why not using byte?
There was a problem hiding this comment.
Habit - since it's a local variable it doesn't make a difference.
💔 Backport failed
You can use sqren/backport to manually backport by running |
Allow individual queries within a sequence to be ran multiple times through using the [runs=number] construct as a suffix without having to redeclare the query. sequence queryA [runs=2] queryB queryC [runs=3] queryD is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise. (cherry picked from commit c7ef3a6)
|
/cc @jrodewig |
Allow individual queries within a sequence to be ran multiple times through using the [runs=number] construct as a suffix without having to redeclare the query. sequence queryA [runs=2] queryB queryC [runs=3] queryD is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise. (cherry picked from commit c7ef3a6)
|
what's up with the brackets? the before, it just had exactly one meaning that was used in a lot of contexts. it wasn't on accident that it always contained an event filter: some of those usages: terms in a also the placement (after i would expect this to be more intuitive: (again, choice of word aside) |
|
Hi Ross. Thanks for the feedback. tl;drTo avoid stretching Long storyThere were several discussions going back and forth on how to declare This favors declaring the property as suffix, just like Thanks to your feedback we reconsidered the reuse of |
|
I like it! Thanks! |
Allow individual queries within a sequence to be repeated through a dedicated keyword without having physical duplication. Change from using [runs=2] to "with runs=2" Before: sequence queryA [runs=2] queryB queryC [runs=3] queryD Now: sequence queryA with runs=2 queryB queryC with runs=3 queryD Which essentially is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise. Supersedes elastic#75082
Allow individual queries within a sequence to be repeated through a dedicated keyword without having physical duplication. Change from using [runs=2] to "with runs=2" Before: sequence queryA [runs=2] queryB queryC [runs=3] queryD Now: sequence queryA with runs=2 queryB queryC with runs=3 queryD Which essentially is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise. Supersedes #75082
Allow individual queries within a sequence to be repeated through a dedicated keyword without having physical duplication. Change from using [runs=2] to "with runs=2" Before: sequence queryA [runs=2] queryB queryC [runs=3] queryD Now: sequence queryA with runs=2 queryB queryC with runs=3 queryD Which essentially is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise. Supersedes elastic#75082
Allow individual queries within a sequence to be repeated through a dedicated keyword without having physical duplication. Change from using [runs=2] to "with runs=2" Before: sequence queryA [runs=2] queryB queryC [runs=3] queryD Now: sequence queryA with runs=2 queryB queryC with runs=3 queryD Which essentially is the same as: sequence queryA queryA queryB queryC queryC queryC queryD but more concise. Supersedes #75082
Allow individual queries within a sequence to be repeated through a
dedicated keyword without having physical duplication.
sequence
queryA [runs=2]
queryB
queryC [runs=3]
queryD
is the same as:
sequence
queryA
queryA
queryB
queryC
queryC
queryC
queryD
but more concise.