Logstash is an open-source, server-side data processing pipeline that ingests events from many sources, transforms them and sends them to one or more destinations. Developed by Elastic as the “L” in the ELK stack, it sits between log producers and storage, most commonly feeding Elasticsearch for search and Kibana for visualization.
In the monitoring & logs practice for servers, Logstash solves a specific problem: raw logs arrive in inconsistent formats from web servers, applications, firewalls and databases. Logstash parses unstructured text into structured fields, normalizes timestamps, adds context and routes the result, which makes log aggregation and analysis possible at scale.
How the Logstash pipeline works
Every Logstash pipeline has three stages: inputs, filters and outputs. Inputs receive or pull events, filters modify them, and outputs deliver them. Each stage is implemented by plugins, and the pipeline is declared in a configuration file with matching input, filter and output blocks.
Internally, inputs write events into a queue, and a pool of pipeline workers takes batches from that queue and runs them through filters and outputs. By default the number of workers equals the number of CPU cores, and the default batch size is 125 events. Both settings, pipeline.workers and pipeline.batch.size, are the first levers for tuning throughput.
The following table summarizes what each stage does and which plugins appear most often in production configurations.
| Stage | Purpose | Common plugins |
|---|---|---|
| Input | Receive or fetch events | beats, file, syslog, kafka, http, jdbc |
| Filter | Parse, enrich and transform | grok, dissect, date, mutate, geoip, json |
| Output | Deliver events to destinations | elasticsearch, kafka, s3, file, stdout |
| Codec | Decode or encode data at the edges | json, json_lines, multiline, plain |
Parsing and enriching log events
The filter stage is where Logstash adds most of its value. The grok filter matches text against named regular expression patterns, turning an Apache or Nginx access log line into fields such as client IP, method, path, status code and bytes. Hundreds of predefined patterns exist, and custom ones can be added.
Because grok relies on regular expressions, it is CPU-intensive and can slow down badly on lines that almost match. For logs with fixed delimiters, the dissect filter splits text by position and separators and is considerably faster. Experienced engineers use dissect first and reserve grok for irregular formats.
| Filter | What it does | Typical use |
|---|---|---|
| grok | Regex-based pattern extraction | Free-form application and access logs |
| dissect | Delimiter-based field splitting | Fixed-format logs at high volume |
| date | Parses timestamps into @timestamp | Correct event time instead of ingest time |
| mutate | Renames, removes or converts fields | Schema cleanup and type conversion |
| geoip | Adds location from an IP address | Visitor maps and security analysis |
| drop | Discards matching events | Filtering health check noise |
Conditionals such as if [status] >= 500 let one pipeline route events differently, for example sending server errors to an alerting system while storing everything else. Pipeline-to-pipeline communication allows complex flows to be split into smaller, separately tuned pipelines.
Reliability, queues and performance
By default Logstash uses an in-memory queue, which is fast but loses buffered events if the process crashes. Enabling the persistent queue writes events to disk first and gives at-least-once delivery across restarts. Events that an output cannot accept, such as documents rejected by Elasticsearch for mapping conflicts, can go to a dead letter queue for later inspection.
Logstash runs on the Java virtual machine, so it needs noticeably more memory than lightweight shippers. A heap of 1 to 4 GB is a common starting point, and the JVM heap should not exceed about half of the available RAM. Throughput per instance varies widely, from a few thousand to tens of thousands of events per second, depending on filter complexity and hardware.
| Setting | Default | Effect of raising it |
|---|---|---|
| pipeline.workers | Number of CPU cores | More parallel filter and output work |
| pipeline.batch.size | 125 events | Larger bulk requests, more memory per worker |
| queue.type | memory | persisted adds durability at some speed cost |
| queue.max_bytes | 1 GB for persisted queue | Longer buffering during outages |
| JVM heap (-Xmx) | 1 GB | Room for bigger batches and lookups |
Logstash compared with other log shippers
Logstash is a heavyweight processor, not a lightweight collector. A typical architecture places Filebeat or another small agent on each server to tail files and forward them, with Logstash running centrally to do the expensive parsing. Alternatives such as Fluentd and Fluent Bit fill similar roles with different trade-offs.
| Tool | Language | Resource footprint | Best role |
|---|---|---|---|
| Logstash | Java and Ruby (JRuby) | High, JVM-based | Central parsing and enrichment |
| Filebeat | Go | Very low | Edge shipping from each server |
| Fluentd | Ruby and C | Moderate | Unified logging with many plugins |
| Fluent Bit | C | Very low | Edge collection, containers, Kubernetes |
| Elasticsearch ingest pipelines | Java | Uses cluster resources | Simple parsing without a separate service |
Common mistakes and limitations
- Running Logstash on every server wastes memory; use lightweight shippers at the edge instead.
- Leaving the date filter out makes events carry ingest time, which breaks timelines during backlogs.
- Unanchored grok patterns cause slow matching and timeouts on high-volume streams.
- Ignoring _grokparsefailure tags hides unparsed events from dashboards and alerts.
- Using only the memory queue for critical audit logs risks silent data loss.
Logstash also adds operational complexity: another JVM service to monitor, upgrade and scale. For small deployments with simple formats, shipping directly from Filebeat to Elasticsearch ingest pipelines is often the simpler and cheaper design.
The simple explanation
Servers write diaries called logs, but every program writes in its own style. Some put the date first, some last, some mix everything into one long line.
Logstash works like a sorting office for those diaries. It collects the pages, reads each one, pulls out the important details such as the time, the visitor and the error, and files them neatly in one place. After that, people can search and chart all logs together instead of reading thousands of messy files one by one.
How it is used in practice
A hosting provider runs about 60 web servers with Nginx and PHP-FPM. Filebeat on each machine forwards access and error logs to two central Logstash nodes, each with 8 pipeline workers, a 4 GB heap and a persistent queue.
The Logstash pipeline uses dissect for the fixed Nginx access format, grok for PHP error messages, the date filter to restore original timestamps and geoip to add country data. Events with status codes of 500 or higher are copied to a separate index that drives alerting, while health check requests are dropped to save storage.
During a two-hour Elasticsearch maintenance window, the persistent queues buffer roughly 9 million events and replay them afterward. As a result, the operations team loses no log data and can trace a spike of 502 errors to one overloaded PHP worker pool within minutes.