Sobes.tech
Middle

What is the difference between Fluentd and Logstash?

sobes.tech AI

Answer from AI

Logstash is an open-source server data processing pipeline that dynamically ingests data from multiple sources, transforms it, and sends it to selected destinations. It is part of the ELK stack (Elasticsearch, Logstash, Kibana).

Fluentd is an open-source data collector for unified logging. It has a modular structure and is more lightweight compared to Logstash, making it suitable for microservices architectures and deployment on edge nodes.

Main differences:

Criterion Fluentd Logstash
Architecture Proprietary, lightweight JVM-based, resource-intensive
Performance High, low resource consumption Can be high with large data volumes
Plugins Over 1000 available plugins Less than 200 available plugins
Plugin language Ruby, C Ruby
Flexibility High, modular Less flexible
Parsing Uses Ruby DSL Uses Grok
Operating system Linux, macOS, Windows Linux, macOS, Windows

Example Fluentd configuration for log collection and sending to Elasticsearch:

# source plugin to collect logs from a file
<source>
  @type tail
  path /var/log/myapp/access.log
  pos_file /var/log/td-agent/pos/access.log.pos
  tag myapp.access
  format apache
</source>

# match plugin to send logs to Elasticsearch
<match myapp.access>
  @type elasticsearch
  host elasticsearch.example.com
  port 9200
  logstash_format true
  logstash_prefix myapp
  index_name myapp_logs
  type_name myapp_type
</match>

Example Logstash configuration for log collection and sending to Elasticsearch:

# input plugin to collect logs from a file
input {
  file {
    path => "/var/log/myapp/access.log"
    start_position => "beginning"
  }
}

# filter plugin to parse log data
filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}" }
  }
}

# output plugin to send logs to Elasticsearch
output {
  elasticsearch {
    hosts => ["elasticsearch.example.com:9200"]
    index => "myapp-logs-%{+YYYY.MM.dd}"
  }
}