What is Fluentd? Collecting, routing, and buffering logs on Kubernetes
Understand Fluentd as a unified logging layer: plugins, tags, routing, filters, parsers, and buffers, a real pipeline for Kubernetes, and when to use Fluent Bit, Vector, or the OpenTelemetry Collector.
Kubernetes$ fluentd --dry-run -c fluent.conf▍Every application writes logs, but each one does it its own way: free text, JSON, multiline stack traces. And every team wants to send them somewhere different — Elasticsearch, S3, Loki, a SIEM. Without a layer in between, this turns into a web of point-to-point integrations. Fluentd was born to be that layer: collect from anywhere, standardize, and deliver to any destination.
What Fluentd is
Fluentd is an open source log collector that describes itself as a unified logging layer. It was created at Treasure Data, is written in Ruby with performance-critical parts in C, and is a CNCF graduated project — the same umbrella that now includes Fluent Bit.
The core idea: every log that comes in becomes an event with three parts:
- tag: a dot-separated string (
kubernetes.var.log.containers.api...) that identifies the source and drives routing; - time: the event timestamp;
- record: the content, as a JSON object.
Concepts: plugins, tags, and routing
Almost everything in Fluentd is a plugin, declared with @type inside directives:
| Directive / concept | Role |
|---|---|
<source> |
Input plugin: where events come from (tail, forward, http, syslog) |
<parse> |
Parser: turns text into a structured record (json, regexp, multiline) |
<filter> |
Modifies, enriches, or drops events (record_transformer, grep) |
<match> |
Output plugin: where events go (elasticsearch, s3, forward, stdout) |
<buffer> |
How the output groups, stores, and retries data |
<label> |
Groups filters and outputs into a separate flow |
Routing is done with tag patterns: * matches exactly one tag part, ** matches zero or more parts, and {a,b} matches alternatives. <match> blocks are evaluated in file order and the first one that matches wins — that is why a catch-all <match **> always goes last.
Community plugins are Ruby gems and are installed with fluent-gem:
fluent-gem install fluent-plugin-kubernetes_metadata_filter
fluent-gem install fluent-plugin-elasticsearch
A real pipeline for Kubernetes
On Kubernetes, the kubelet writes container output to /var/log/containers/*.log. With containerd or CRI-O, each line follows the CRI format: timestamp, stream, a full/partial line marker, and the message. The configuration below reads those files, adds Kubernetes metadata, and ships everything to Elasticsearch:
# 1. Input: read the node's container logs
<source>
@type tail
@id in_containers
path /var/log/containers/*.log
exclude_path ["/var/log/containers/fluentd*.log"]
pos_file /var/log/fluentd-containers.log.pos
tag kubernetes.*
read_from_head true
<parse>
# CRI format: "<timestamp> <stdout|stderr> <F|P> <message>"
@type regexp
expression /^(?<time>[^ ]+) (?<stream>stdout|stderr) (?<logtag>[FP]) (?<log>.*)$/
time_format %Y-%m-%dT%H:%M:%S.%N%:z
</parse>
</source>
# 2. Filters: enrich every event
<filter kubernetes.**>
@type kubernetes_metadata
</filter>
<filter kubernetes.**>
@type record_transformer
<record>
cluster prod-us-east-1
environment production
</record>
</filter>
# 3. Output: Elasticsearch with an on-disk buffer
<match kubernetes.**>
@type elasticsearch
host elasticsearch.logging.svc
port 9200
scheme https
logstash_format true
logstash_prefix k8s
<buffer>
@type file
path /var/log/fluentd-buffers/es.buffer
flush_interval 5s
chunk_limit_size 8MB
total_limit_size 4GB
retry_type exponential_backoff
retry_max_interval 60s
retry_timeout 12h
overflow_action block
</buffer>
</match>
A few important details:
- With
tag kubernetes.*, the*is replaced with the file path (with/turned into.). That is the name thekubernetes_metadatafilter parses to get the pod, namespace, and container, so it can query the API and add labels and annotations. - The
pos_filerecords how far each file has been read. Without it, a restart either rereads everything or loses data. - The
exclude_pathkeeps Fluentd from collecting its own logs and looping. - For OpenSearch, the
fluent-plugin-opensearchplugin uses@type opensearchwith very similar parameters. For S3,fluent-plugin-s3uses@type s3withs3_bucket,s3_region, andpath.
Before applying it, validate the syntax with fluentd --dry-run -c fluent.conf.
Buffers and reliability
Outputs never write event by event: they group events into chunks inside a buffer and flush them periodically. This is where Fluentd gains (or loses) reliability:
@type filevsmemory: a memory buffer is faster but disappears if the pod restarts. In production, preferfile— and, in a DaemonSet, put it on ahostPathvolume so it survives pod restarts.- Retries: with
retry_type exponential_backoff, the wait between attempts grows up toretry_max_interval.retry_timeout(orretry_max_times) defines when to give up;retry_forever truenever gives up. - Backpressure:
total_limit_sizecaps the buffer size. When it fills up,overflow_actiondecides what happens:throw_exception(the default),block(holds back the input), ordrop_oldest_chunk. - Plan B: a
<secondary>block with@type secondary_filewrites chunks that exhausted their retries to disk, so you can reprocess them later.
Monitor buffers and retries with monitor_agent or fluent-plugin-prometheus.
Running as a DaemonSet on Kubernetes
The standard pattern is one Fluentd pod per node, via a DaemonSet, mounting the host’s /var/log. It needs a ServiceAccount allowed to get, list, and watch pods and namespaces for the metadata filter to work. The project maintains an official chart:
helm repo add fluent https://fluent.github.io/helm-charts
helm repo update
helm show values fluent/fluentd > values-fluentd.yaml
helm install fluentd fluent/fluentd \
--namespace logging --create-namespace \
-f values-fluentd.yaml
There are also the fluent/fluentd-kubernetes-daemonset images, with variants prepackaged per destination (Elasticsearch, S3, Kafka, CloudWatch, and others). Set CPU and memory requests and limits.
Fluentd vs Fluent Bit
Both come from the same community and complement each other:
| Criterion | Fluentd | Fluent Bit |
|---|---|---|
| Language | Ruby + C | C |
| Memory footprint | Tens of MB | A few MB |
| Plugins | Hundreds, as community gems | Built into the binary |
| Extensibility | Very high (Ruby) | Lower, with Lua and WASM support |
| Typical role | Central aggregator | Lightweight agent on every node |
A common architecture: Fluent Bit as a DaemonSet collecting and parsing on the nodes, sending over the forward protocol to a Fluentd aggregator (Deployment or StatefulSet), which handles complex routing, heavy buffering, and destination credentials.
What about Vector and the OpenTelemetry Collector?
Fluentd is no longer alone. Vector (written in Rust) is a fast observability pipeline with its own transformation language (VRL). The OpenTelemetry Collector has become the standard for collecting logs, metrics, and traces with a single data model and the OTLP protocol — and Fluent Bit itself already speaks OTLP. We compare these options in telemetry pipelines and show the single-collection strategy in OpenTelemetry as a single collection layer.
When to choose Fluentd
- Choose Fluentd when you need a specific plugin that only exists in its ecosystem, complex tag-based routing, or an aggregator with robust buffering — or when you already run a stable Fluentd pipeline in production.
- Prefer Fluent Bit as the node agent, especially when resources are tight.
- Consider the OpenTelemetry Collector if the goal is to unify logs, metrics, and traces under one standard; or Vector, if performance and advanced transformations matter more.
Whatever the collector, the destination matters just as much: if you use Loki, see how to query logs with LogQL and how it fits into the LGTM stack.
Summary
- Fluentd is a CNCF graduated unified logging layer that turns everything into events with a tag, a time, and a record
-
<source>,<filter>, and<match>make up the pipeline; tags drive routing and the first matching<match>wins - On Kubernetes, it runs as a DaemonSet reading
/var/log/containerswith apos_fileand cluster metadata - File buffers, retries with backoff, and
overflow_actiondefine reliability - Fluent Bit is the lightweight agent; Fluentd shines as an aggregator
- Vector and the OpenTelemetry Collector are modern alternatives worth evaluating
A good log pipeline is one nobody thinks about — until the day the destination goes down and the buffer holds everything without losing a single line.