-
Notifications
You must be signed in to change notification settings - Fork 5k
Filebeat 9.x bulk requests contain double newline, breaking ES-compatible endpoints #49558
Copy link
Copy link
Open
Enhancement
Copy link
Labels
Team:Elastic-Agent-Data-PlaneLabel for the Agent Data Plane teamLabel for the Agent Data Plane team
Description
Description
Filebeat 9.x produces NDJSON bulk request bodies with double newlines (\n\n) between events. While Elasticsearch tolerates empty lines, ES-compatible endpoints (Axiom, OpenSearch) reject them:
400 Bad Request: invalid event at index 1: ReadObject: expect { or , or } or n, but found \u0000
Root cause
In 9.x, events are pre-encoded in the pipeline queue (event_encoder.go). The Marshal/AddRaw call appends a trailing \n to the encoded bytes. When the bulk body assembler later writes these bytes via AddRaw(RawEncoding{...}), it unconditionally appends another \n, producing an empty line.
This didn't exist in 8.x because events were encoded inline during bulk assembly (no RawEncoding path).
Steps to reproduce
- Configure
filebeat-oss:9.3.1with afilestreaminput andoutput.elasticsearchpointing to any non-Elasticsearch endpoint (e.g. Axiom's ES compatibility API) - Ingest a log file
- Observe
400 Bad Requestwith null byte error on every bulk write - Same config with
filebeat-oss:8.11.1(usingcontainerinput) works fine
Affected versions
- 9.0.0 through 9.3.1 (current latest)
- Both
-ossand standard builds - Both
jsonEncoderandgzipEncoderpaths
Fix
PR #49557 — checks if RawEncoding bytes already end with \n and skips the extra one.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Team:Elastic-Agent-Data-PlaneLabel for the Agent Data Plane teamLabel for the Agent Data Plane team
Type
Fields
Give feedbackNo fields configured for Enhancement.