RousselTMLEARNING

Observability

Fluent Bit on Kubernetes: DaemonSet, multiline, buffering and monitoring

Deploy Fluent Bit on Kubernetes with Helm, enrich with the kubernetes filter, handle multiline logs, configure the disk buffer and backpressure, and monitor the agent.

1. Installing with Helm #

A ready-to-use DaemonSet.

Commands #

helm repo add fluent https://fluent.github.io/helm-charts
helm upgrade --install fluent-bit fluent/fluent-bit -n logging --create-namespace -f values.yaml
# values.yaml (extrait) : le chart accepte la configuration au format classique
config:
  inputs: |
    [INPUT]
        Name              tail
        Path              /var/log/containers/*.log
        multiline.parser  docker, cri
        Tag               kube.*
        Mem_Buf_Limit     50MB
        Skip_Long_Lines   On
        storage.type      filesystem
  filters: |
    [FILTER]
        Name                kubernetes
        Match               kube.*
        Merge_Log           On
        Keep_Log            Off
        K8S-Logging.Parser  On
        K8S-Logging.Exclude On
  outputs: |
    [OUTPUT]
        Name        loki
        Match       kube.*
        Host        loki-gateway.logging.svc
        Port        80
        Labels      job=fluent-bit
        Label_keys  $kubernetes['namespace_name'],$kubernetes['container_name']
Good practice: Merge_Log On parses applications' JSON logs and puts their fields at the top level; the fluentbit.io/parser and fluentbit.io/exclude annotations let teams pick a parser or exclude their pods.

2. Multiline logs #

Java and Python stack traces.

multiline #

A Java exception spans 50 lines: without processing, each line becomes a record. The built-in multiline parsers (docker, cri, java, python, go) or custom ones group them:

[MULTILINE_PARSER]
    name          java_exceptions
    type          regex
    flush_timeout 1000
    rule  "start_state"  "/^\d{4}-\d{2}-\d{2} .*/"   "cont"
    rule  "cont"         "/^\s+at .*|^Caused by: .*/"   "cont"

[FILTER]
    name                  multiline
    match                 kube.*
    multiline.key_content log
    multiline.parser      java, java_exceptions

3. Buffering and backpressure #

Lose nothing, saturate nothing.

Settings #

ParameterEffect
mem_buf_limitMemory cap for an input: beyond it, reading is paused (backpressure)
storage.type filesystemPending chunks are written to disk and survive a restart
storage.total_limit_size (output)Maximum disk buffer size per destination
retry_limit (output)Number of retries (no_limits to retry indefinitely)
Common mistake: With a memory-only buffer, a Loki outage of a few minutes can lose logs or pause reading. Enable the disk buffer on production nodes.

Monitoring Fluent Bit #

curl -s localhost:2020/api/v1/health
curl -s localhost:2020/api/v2/metrics/prometheus | grep -E 'fluentbit_(input_records|output_(proc_records|errors|retries_failed))_total'
- alert: FluentBitOutputErrors
  expr: sum by (name) (rate(fluentbit_output_retries_failed_total[5m])) > 0
  for: 10m
  labels: { severity: warning }

Related articles

Fluent Bit: pipeline inputs in detail

Everything about Fluent Bit inputs: the role of tags, reading files with tail (positions, rotation, multiline…

Fluent Bit: parsers and filters, structuring and transforming logs

Structure and transform logs in Fluent Bit: parsers (json, regex, logfmt, ltsv), multiline parsers, the kuber…

Fluent Bit: outputs, routing and delivery reliability

Send Fluent Bit data: routing with Match and Match_Regex, Loki, Elasticsearch/OpenSearch, OpenTelemetry, S3, …

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!