RousselTMLEARNING

Observability

Logstash: filters, grok and dissect

Written version of the video lessons: essential filters (mutate, date, json, kv, drop), the grok plugin and its patterns, dissect, and how to choose between them.

1. Filters #

Transforming events.

Essential filters #

Raw line, splitting, date, mutate, ECS document.
FilterRole
mutaterename, convert, remove, add fields
dateset @timestamp from a date field
json / kvdecode JSON or key=value pairs
dropdrop useless events
fingerprintcompute a stable ID
filter {
  json   { source => "message" skip_on_invalid_json => true }
  date   { match => ["time", "ISO8601"] remove_field => ["time"] }
  mutate {
    rename  => { "lvl" => "[log][level]" }
    convert => { "[http][response][status_code]" => "integer" }
  }
  if [url][path] == "/health" { drop {} }
}

2. The grok plugin #

Named patterns.

Principle #

grok maps named regular expressions to fields: %{IP:[source][ip]} captures an IP address into source.ip. More than 120 patterns are provided (IP, NUMBER, TIMESTAMP_ISO8601, COMBINEDAPACHELOG…).

# 2026-11-09T10:15:00Z ERROR 203.0.113.7 GET /api/commande 500 132ms
grok {
  match => { "message" => "%{TIMESTAMP_ISO8601:ts} %{LOGLEVEL:[log][level]} %{IP:[source][ip]} %{WORD:[http][request][method]} %{URIPATH:[url][path]} %{NUMBER:[http][response][status_code]:int} %{NUMBER:duree_ms:int}ms" }
}
Good practice: Build your patterns with the Kibana Grok Debugger (Dev Tools) and anchor them (^…$): an unanchored pattern that fails scans the whole line and costs a lot of CPU.
Common mistake: Ignoring the _grokparsefailure tag: unmatched lines are shipped without structure and skew dashboards. Monitor it and send those events to a separate data stream.

3. dissect or grok? #

Choosing the right tool.

dissect #

dissect splits the line on fixed delimiters, without regular expressions: it is much faster, but cannot handle a variable format.

dissect {
  mapping => { "message" => "%{ts} %{[log][level]} %{[source][ip]} %{[http][request][method]} %{[url][path]} %{[http][response][status_code]} %{duree}" }
}
dissectgrok
Methoddelimitersregular expressions
Performancevery fastmore costly
Variable formatnoyes (alternatives, optional parts)
Typingwith mutate or convert_datatypein the pattern (:int)
Good practice: Combine both: dissect for the fixed header of the line, grok only on the variable part.

Related articles

Logstash: role, pipeline concept and installation

Written version of the video lessons: what Logstash is for, how a pipeline works (inputs, filters, outputs, q…

Logstash: inputs and outputs

Written version of the video lessons: common inputs (beats, file, tcp/udp, http, kafka, jdbc) and outputs (el…

Logstash: managing plugins and adopting Elastic Common Schema (ECS)

Written version of the video lessons: list, install, update and bundle Logstash plugins offline; understand E…

Keep learning

Support us

♥ SUPPORT US

Support RousselTM Learning

Courses, articles, labs and certificates stay free with no intrusive ads. A voluntary contribution, of any amount you choose, pays for hosting, lab environments and new content.

Contribute with PayPal Any amount · card or PayPal accountLearn more
QR code PayPal
Or scan this QR code with your phone

Thank you, every contribution counts!