The built-in pattern library
14 min · 2 ejercicio(s)
Elasticsearch ships with more than 300 named patterns. You will use a dozen of them all the time:
| Pattern | Matches | Example |
|---|---|---|
WORD |
Letters, digits, _ |
GET, sshd |
NOTSPACE |
Anything up to the next space | /products?id=12%27 |
INT, NUMBER |
Integer, decimal number | 500, 129.90 |
IP, IPORHOST |
IPv4/IPv6, or a host name | 203.0.113.66 |
USERNAME, USER |
User names | h.yilmaz |
HOSTNAME |
DNS host names | srv-web-01 |
QUOTEDSTRING (QS) |
Text in double quotes, including the quotes | "sqlmap/1.8.3" |
LOGLEVEL |
INFO, WARN, ERROR, DEBUG, … |
WARN |
SYSLOGTIMESTAMP |
Mar 11 02:14:03 |
BSD syslog |
HTTPDATE |
13/Mar/2026:21:07:00 +0000 |
Apache/nginx |
TIMESTAMP_ISO8601 |
2026-03-13T21:19:50.123Z |
Applications, JSON |
URIPATHPARAM |
/products?id=12 |
Request path with query |
DATA, GREEDYDATA |
Anything (lazy, greedy) |
Parsing an nginx access line by hand
203.0.113.66 - - [13/Mar/2026:21:07:00 +0000] "GET /products?id=12%27 HTTP/1.1" 500 312 "-" "sqlmap/1.8.3#stable (https://sqlmap.org)"FROM lab-raw
| WHERE event.dataset == "nginx.access"
| GROK message """%{IP:client} - %{NOTSPACE:auth} \[%{HTTPDATE:time}\] "%{WORD:method} %{NOTSPACE:request} HTTP/%{NUMBER:http_version}" %{INT:status} %{INT:bytes}"""
| STATS requests = COUNT(*) BY statusComposite patterns
Some patterns describe a whole log format. %{COMBINEDAPACHELOG} parses the Apache/nginx "combined" format in one go. In Elasticsearch it produces ECS field names, already converted to numbers where it makes sense:
FROM lab-raw
| WHERE event.dataset == "nginx.access"
| GROK message "%{COMBINEDAPACHELOG}"
| KEEP source.address, http.request.method, url.original, http.response.status_code, user_agent.originalThe same idea exists for syslog (%{SYSLOGLINE}) and many other formats. Check the pattern files before you write a format from scratch.
🔎 Profundiza: funciones, errores habituales y práctica
ECS compatibility of the built-in patterns
Since 8.0, Elasticsearch uses the ECS-compatible versions of the composite patterns: COMBINEDAPACHELOG writes source.address, http.request.method, http.response.status_code and so on instead of the legacy names clientip, verb and response. In an ingest pipeline you can switch back with "ecs_compatibility": "disabled" if old dashboards rely on the legacy names.
Percent-encoded URLs
Browsers and attack tools send spaces and quotes percent-encoded: the sqlmap payload id=12 AND 1=1 arrives as id=12%20AND%201=1, a single quote as %27. That's why NOTSPACE works for the request. If you search raw logs for an attack string, search for the encoded form, or decode it after parsing.
Reading pattern definitions
The pattern files on GitHub are the documentation. grok-patterns holds the basics, httpd the web server formats, linux-syslog syslog. When a built-in pattern surprises you, look at its definition, it's usually one line.