Practice: reading and matching log lines
12 min · 2 ejercicio(s)
Cheat sheet
| You want | Pattern |
|---|---|
| A word / anything up to a space | %{WORD:x} / %{NOTSPACE:x} |
| A number | %{INT:x}, %{NUMBER:x} |
| An IP or host | %{IP:x}, %{IPORHOST:x} |
| Text in brackets | \[%{DATA:x}\] |
| Text in quotes | "%{DATA:x}" or %{QS:x} |
| The rest of the line | %{GREEDYDATA:x} (only at the end) |
A literal [, (, . |
\[, \(, \. |
Typical mistakes
- Missing the exact spacing.
INFO [auth]has two spaces, a pattern with one doesn't match. Use\s+. - Forgetting escapes.
sshd[%{INT:pid}]is an invalid regex,sshd\[%{INT:pid}\]works. - Normal quotes around a pattern with backslashes. In ES|QL use
"""…""". - Trusting a count without checking nulls. Run once with
KEEP message, fieldand look at rows where the field isnull.