Skip to content

out_kafka: add add_timestamp option to suppress timestamp field#11579

Open
piyushka-ally wants to merge 1 commit intofluent:masterfrom
piyushka-ally:out_kafka/add-timestamp-opt
Open

out_kafka: add add_timestamp option to suppress timestamp field#11579
piyushka-ally wants to merge 1 commit intofluent:masterfrom
piyushka-ally:out_kafka/add-timestamp-opt

Conversation

@piyushka-ally
Copy link

@piyushka-ally piyushka-ally commented Mar 18, 2026

The Kafka output plugin unconditionally injects an @timestamp field into every record when using json or msgpack formats. This prevents users from piping data through Fluent Bit into downstream Kafka consumers (e.g. JDBC sink connector) that enforce a strict schema, as the extra field causes schema mismatch errors.

Add a new boolean config option add_timestamp (default: true) that controls whether the timestamp field is injected into the output record. When set to false, the field is omitted entirely.

This is fully backward compatible — existing configurations are unaffected since the option defaults to true.

Example usage to disable timestamp injection:

[OUTPUT]
    Name          kafka
    Match         *
    Brokers       localhost:9092
    Topics        my-topic
    add_timestamp false

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • Example configuration file for the change
  • [N/A] Debug log output from testing the change
  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

If this is a change to packaging of containers or native binaries then please confirm it works for all targets.

  • [N/A] Run local packaging test showing all targets (including any new ones) build.
  • [N/A] Set ok-package-test label to test for all targets (requires maintainer to do).

Documentation

  • Documentation required for this feature

Backporting

  • [N/A] Backport to latest stable release.

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

Summary by CodeRabbit

  • New Features
    • Added add_timestamp configuration option to the Kafka output plugin
    • Timestamp fields are now appended to records by default
    • Can be disabled to suppress timestamp fields and reduce message size

The Kafka output plugin unconditionally injects an @timestamp field
into every record when using json or msgpack formats. This prevents
users from piping data through Fluent Bit into downstream Kafka
consumers (e.g. JDBC sink connector) that enforce a strict schema,
as the extra field causes schema mismatch errors.

Add a new boolean config option `add_timestamp` (default: true) that
controls whether the timestamp field is injected into the output
record. When set to false, the field is omitted entirely.

This is fully backward compatible — existing configurations are
unaffected since the option defaults to true.

Example usage to disable timestamp injection:

    [OUTPUT]
        Name          kafka
        Match         *
        Brokers       localhost:9092
        Topics        my-topic
        add_timestamp false

Signed-off-by: Piyush Kanti Chanda <piyush.chanda@databricks.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a7ab491f-83b5-4f5c-88ab-124741e8d18d

📥 Commits

Reviewing files that changed from the base of the PR and between 962855c and 8e33e89.

📒 Files selected for processing (2)
  • plugins/out_kafka/kafka.c
  • plugins/out_kafka/kafka_config.h

📝 Walkthrough

Walkthrough

The pull request introduces a new configuration option add_timestamp (default true) to the Kafka output plugin. This option conditionally appends a timestamp field to records, with the message-building logic and struct definition adjusted to support this feature.

Changes

Cohort / File(s) Summary
Kafka Timestamp Configuration
plugins/out_kafka/kafka.c, plugins/out_kafka/kafka_config.h
Introduces add_timestamp boolean configuration option (default true) to conditionally append timestamp fields to Kafka records. Updates struct field definition and adjusts message-building logic for JSON/MSG formats to conditionally allocate space and emit timestamp based on configuration flag.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 Tick-tock, a timestamp takes flight,
A config toggle, shining bright!
Messages dance through Kafka streams,
With time-stamped dreams or timeless schemes. ⏰✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding an add_timestamp option to the Kafka output plugin to allow suppressing the timestamp field.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant