Operations 10 min read

Mastering ELK: Compare Logstash vs Filebeat Architectures and Solve Common Logging Challenges

This guide compares three ELK deployment architectures—Logstash‑only, Filebeat‑assisted, and cache‑queue‑enhanced—explains their trade‑offs, and provides concrete Logstash/Filebeat multiline, timestamp, and module‑filtering configurations to address typical logging problems.

IT Architects Alliance
IT Architects Alliance
IT Architects Alliance
Mastering ELK: Compare Logstash vs Filebeat Architectures and Solve Common Logging Challenges

Overview

ELK is a widely used centralized logging stack composed of Beats, Logstash, Elasticsearch, and Kibana. It provides real‑time log collection, storage, and visualization.

Common Deployment Architectures

Logstash as Log Collector

Deploy a Logstash instance on each application server to collect, filter, format, and forward logs to Elasticsearch; Kibana visualizes the data. This architecture consumes significant resources on the application hosts.

Logstash collector architecture
Logstash collector architecture

Filebeat as Log Collector

Replace Logstash on the application side with the lightweight Filebeat. Filebeat forwards logs to Logstash (or directly to Elasticsearch) and is the most common deployment pattern.

Filebeat collector architecture
Filebeat collector architecture

Cache Queue Between Filebeat and Logstash

Insert a Redis (or other message‑queue) layer between Filebeat and Logstash to buffer data, improve reliability, and balance the load of Logstash and Elasticsearch under high‑throughput scenarios.

Cache queue architecture
Cache queue architecture

Architecture Summary

The Logstash‑only architecture is rarely used because of its resource consumption. The Filebeat‑plus‑Logstash architecture is the dominant choice. Adding a cache queue is optional and only required for specific high‑throughput or reliability requirements.

Typical Problems and Solutions

Multiline Log Merging

Logs that span multiple lines must be merged into a single event.

Filebeat Multiline Configuration

Filebeat multiline config
Filebeat multiline config

pattern : regular expression that identifies the start of a new log entry.

negate : false merges lines matching the pattern to the previous line; true merges non‑matching lines.

match : after appends the line to the previous line’s end; before prepends it.

<code>pattern: '\[' negate: true match: after</code>

This example appends lines that do **not** start with [ to the previous line.

Logstash Multiline Configuration

Logstash multiline config
Logstash multiline config

In Logstash use the multiline filter. The what option previous corresponds to Filebeat’s after, and next corresponds to before. A typical pattern is:

pattern => "%{LOGLEVEL}\s*]"
what => "previous"

Built‑in patterns such as LOGLEVEL are defined in the Logstash patterns repository: https://github.com/logstash-plugins/logstash-patterns-core/tree/master/patterns

Replacing Kibana Time Field with Log Timestamp

Kibana shows the ingestion time by default. Use Logstash grok and date filters to extract the timestamp from the log message.

Example log line:

[DEBUG][20170811 10:07:31,359][DefaultBeanDefinitionDocumentReader:106] Loading bean definitions

Create a custom pattern file (e.g., customer_patterns) containing:

CUSTOMER_TIME %{YEAR}%{MONTHNUM}%{MONTHDAY}\s+%{TIME}

Reference the pattern in the Logstash filter:

Logstash grok and date config
Logstash grok and date config

Alternatively embed the pattern directly:

Inline pattern example
Inline pattern example

Filtering Logs by System Module

Add a custom field (e.g., log_from) to identify the originating module, then filter in Kibana, or create separate Elasticsearch indices per module.

Filebeat example adding log_from:

Filebeat add log_from field
Filebeat add log_from field

Logstash output example using document_type to route to different indices:

Logstash output index by type
Logstash output index by type

Conclusion

The three ELK deployment patterns—Logstash‑only, Filebeat‑plus‑Logstash, and Filebeat‑plus‑Redis‑plus‑Logstash—address different resource and reliability requirements. Multiline merging, timestamp extraction, and module‑level filtering are implemented via Filebeat or Logstash configuration, demonstrating ELK’s flexibility for log analysis and broader monitoring use cases.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

OperationsloggingELKLogstashKibanaFilebeat
IT Architects Alliance
Written by

IT Architects Alliance

Discussion and exchange on system, internet, large‑scale distributed, high‑availability, and high‑performance architectures, as well as big data, machine learning, AI, and architecture adjustments with internet technologies. Includes real‑world large‑scale architecture case studies. Open to architects who have ideas and enjoy sharing.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.