Skip to content

Commit b70cbc9

Browse files
jrodewigrw-access
andcommitted
[DOCS] Add EQL syntax page (#51821)
Adds documentation for basic EQL syntax. Joins, sequences, and other syntax to be added as its supported in future development. Co-Authored-By: Ross Wolf <[email protected]>
1 parent 0610eb5 commit b70cbc9

File tree

2 files changed

+243
-1
lines changed

2 files changed

+243
-1
lines changed

docs/reference/eql/index.asciidoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Consider using EQL if you:
2929
[[eql-toc]]
3030
=== In this section
3131

32-
* <<eql-requirements,EQL requirements>>
32+
* <<eql-requirements>>
33+
* <<eql-syntax>>
3334

3435
include::requirements.asciidoc[]
36+
include::syntax.asciidoc[]

docs/reference/eql/syntax.asciidoc

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
[role="xpack"]
2+
[testenv="basic"]
3+
[[eql-syntax]]
4+
== EQL syntax reference
5+
6+
experimental::[]
7+
8+
[IMPORTANT]
9+
====
10+
{es} supports a subset of EQL syntax.
11+
====
12+
13+
[discrete]
14+
[[eql-basic-syntax]]
15+
=== Basic syntax
16+
17+
EQL queries require an event type and a matching condition. The `where` keyword connects them.
18+
19+
[source,eql]
20+
----
21+
event_type where condition
22+
----
23+
24+
For example, the following EQL query matches `process` events with a `process.name`
25+
field value of `svchost.exe`:
26+
27+
[source,eql]
28+
----
29+
process where process.name == "svchost.exe"
30+
----
31+
32+
[discrete]
33+
[[eql-syntax-conditions]]
34+
==== Conditions
35+
36+
A condition consists of one or more criteria an event must match.
37+
You can specify and combine these criteria using the following operators:
38+
39+
[discrete]
40+
[[eql-syntax-comparison-operators]]
41+
===== Comparison operators
42+
43+
[source,eql]
44+
----
45+
< <= == != >= >
46+
----
47+
48+
.*Definitions*
49+
[%collapsible]
50+
====
51+
`<` (less than)::
52+
Returns `true` if the value to the left of the operator is less than the value
53+
to the right. Otherwise returns `false`.
54+
55+
`<=` (less than or equal) ::
56+
Returns `true` if the value to the left of the operator is less than or equal to
57+
the value to the right. Otherwise returns `false`.
58+
59+
`==` (equal)::
60+
Returns `true` if the values to the left and right of the operator are equal.
61+
Otherwise returns `false`.
62+
63+
`!=` (not equal)::
64+
Returns `true` if the values to the left and right of the operator are not
65+
equal. Otherwise returns `false`.
66+
67+
`>=` (greater than or equal) ::
68+
Returns `true` if the value to the left of the operator is greater than or equal
69+
to the value to the right. Otherwise returns `false`.
70+
71+
`>` (greater than)::
72+
Returns `true` if the value to the left of the operator is greater than the
73+
value to the right. Otherwise returns `false`.
74+
====
75+
76+
[discrete]
77+
[[eql-syntax-logical-operators]]
78+
===== Logical operators
79+
80+
[source,eql]
81+
----
82+
and or not
83+
----
84+
85+
.*Definitions*
86+
[%collapsible]
87+
====
88+
`and`::
89+
Returns `true` only if the condition to the left and right _both_ return `true`.
90+
Otherwise returns `false.
91+
92+
`or`::
93+
Returns `true` if one of the conditions to the left or right `true`.
94+
Otherwise returns `false.
95+
96+
`not`::
97+
Returns `true` if the condition to the right is `false`.
98+
====
99+
100+
[discrete]
101+
[[eql-syntax-lookup-operators]]
102+
===== Lookup operators
103+
104+
[source,eql]
105+
----
106+
user.name in ("Administrator", "SYSTEM", "NETWORK SERVICE")
107+
user.name not in ("Administrator", "SYSTEM", "NETWORK SERVICE")
108+
----
109+
110+
.*Definitions*
111+
[%collapsible]
112+
====
113+
`in`::
114+
Returns `true` if the value is contained in the provided list.
115+
116+
`not in`::
117+
Returns `true` if the value is not contained in the provided list.
118+
====
119+
120+
[discrete]
121+
[[eql-syntax-math-operators]]
122+
===== Math operators
123+
124+
[source,eql]
125+
----
126+
+ - * / %
127+
----
128+
129+
.*Definitions*
130+
[%collapsible]
131+
====
132+
`+` (add)::
133+
Adds the values to the left and right of the operator.
134+
135+
`-` (Subtract)::
136+
Subtracts the value to the right of the operator from the value to the left.
137+
138+
`*` (Subtract)::
139+
Multiplies the values to the left and right of the operator.
140+
141+
`/` (Divide)::
142+
Divides the value to the left of the operator by the value to the right.
143+
144+
`%` (modulo)::
145+
Divides the value to the left of the operator by the value to the right. Returns only the remainder.
146+
====
147+
148+
[discrete]
149+
[[eql-syntax-strings]]
150+
==== Strings
151+
152+
Strings are enclosed with double quotes (`"`) or single quotes (`'`).
153+
154+
[source,eql]
155+
----
156+
"hello world"
157+
"hello world with 'substring'"
158+
----
159+
160+
[discrete]
161+
[[eql-syntax-wildcards]]
162+
===== Wildcards
163+
164+
You can use the wildcard operator (`*`) within a string to match specific
165+
patterns. You can use wildcards with the `==` (equal) or `!=` (not equal)
166+
operators:
167+
168+
[source,eql]
169+
----
170+
field == "example*wildcard"
171+
field != "example*wildcard"
172+
----
173+
174+
[discrete]
175+
[[eql-syntax-escaped-characters]]
176+
===== Escaped characters
177+
178+
When used within a string, special characters, such as a carriage return or
179+
double quote (`"`), must be escaped with a preceding backslash (`\`).
180+
181+
[source,eql]
182+
----
183+
"example \t of \n escaped \r characters"
184+
----
185+
186+
.*Escape sequences*
187+
[%collapsible]
188+
====
189+
[options="header"]
190+
|====
191+
| Escape sequence | Literal character
192+
|`\n` | A newline (linefeed) character
193+
|`\r` | A carriage return character
194+
|`\t` | A tab character
195+
|`\\` | A backslash (`\`) character
196+
|`\"` | A double quote (`"`) character
197+
|`\'` | A single quote (`'`) character
198+
|====
199+
====
200+
201+
[discrete]
202+
[[eql-syntax-raw-strings]]
203+
===== Raw strings
204+
205+
Raw strings are preceded by a question mark (`?`) and treat backslashes (`\`) as
206+
literal characters.
207+
208+
[source,eql]
209+
----
210+
?"String with a literal 'blackslash' \ character included"
211+
----
212+
213+
You can escape single quotes (`'`) and double quotes (`"`) with a backslash, but
214+
the backslash remains in the resulting string.
215+
216+
[source,eql]
217+
----
218+
?"\""
219+
----
220+
221+
[NOTE]
222+
====
223+
Raw strings cannot contain only a single backslash. Additionally, raw strings
224+
cannot end in an odd number of backslashes.
225+
====
226+
227+
[discrete]
228+
[[eql-syntax-non-alpha-field-names]]
229+
==== Non-alphanumeric field names
230+
231+
Field names containing non-alphanumeric characters, such as underscores (`_`),
232+
dots (`.`), hyphens (`-`), or spaces, must be escaped using backticks (+++`+++).
233+
234+
[source,eql]
235+
----
236+
`my_field`
237+
`my.field`
238+
`my-field`
239+
`my field`
240+
----

0 commit comments

Comments
 (0)