Skip to content

kubernetes_events input plugin cannot handle chunked transfer encoding #11252

@syurevich

Description

@syurevich

Bug Report

Describe the bug

kubernetes_events input plugin cannot handle chunked transfer encoding, as required by HTTP/1.1.

With the "debug" logging level enabled in the Fluent Bit kubernetes_events input plugin, we observed lots of errors. See the logs below.

The ff4, ef7, f10, 134d, etc. are chunk sizes in hexadecimal as per HTTP/1.1 chunked transfer encoding. They are the chunked length headers used by servers (proxies/L7 load balancers) to send streaming HTTP responses when the total length is unknown in advance.

The kubernetes_events input plugin seems to be not designed to handle the chunked encoding markers, so it tries to parse ff4 as JSON, resulting in the "bad formed JSON" error (as printed by flb_plg_debug function).

Moreover, as soon as this error occurs, the watch stream gets stuck and the kubernetes_events input plugin does not receive new k8s events for about 25-40 minutes until it re-requests the watch.

To Reproduce

  • Rubular link if applicable:
  • Example log message if applicable:
[2025/12/03 10:11:01] [debug] [input:kubernetes_events:kubernetes_events.0] could not process payload, incomplete or bad formed JSON: ff4
{"type":"DELETED","object":{ ... }}
...
[2025/12/03 10:51:04] [debug] [input:kubernetes_events:kubernetes_events.0] could not process payload, incomplete or bad formed JSON: ef7
{"type":"DELETED","object":{ ... }}
...
[2025/12/03 11:36:05] [debug] [input:kubernetes_events:kubernetes_events.0] could not process payload, incomplete or bad formed JSON: f10
{"type":"DELETED","object":{ ... }}
...
[2025/12/03 12:31:04] [debug] [input:kubernetes_events:kubernetes_events.0] could not process payload, incomplete or bad formed JSON: 134d
{"type":"DELETED","object":{ ... }}
...

  • Steps to reproduce the problem:

Expected behavior

kubernetes_events input plugin should handle chunked transfer encoding, as required by HTTP/1.1.

Screenshots

Your Environment

  • Version used: fluent bit version=4.2.0
  • Configuration:
    service:
      flush: 5
      log_level: "info"
      scheduler.cap: 60
      scheduler.base: 5
      daemon: false
      storage.metrics: true
      storage.max_chunks_up: 8
      storage.path: /fluent-bit/buffers
      storage.delete_irrecoverable_chunks: true
      storage.backlog.flush_on_shutdown: true
      grace: 29
      http_server: true
      http_listen: 0.0.0.0
      http_port: 2020

    pipeline:
      inputs:
        - name: kubernetes_events
          tag: k8s_events
          kube_token_ttl: 10s
          kube_request_limit: 100
          kube_retention_time: 86400
          log_level: "debug"
          storage.type: filesystem
...
  • Environment name and version (e.g. Kubernetes? What version?): Kubernetes v1.32.9
  • Server type and version:
  • Operating System and version: gardenlinux 1592.14.0
  • Filters and plugins: kubernetes_events

Additional context

The kubernetes_events input plugin stops receiving new k8s events.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions