What's the Purpose of Time_Key in Fluent Bit Parsers?

Better Stack Team
Updated on August 5, 2024

To understand the Time_Key option, it helps to know that when you don't specify this option, Fluent Bit uses the current system time as the timestamp for each log entry.

When you use the Time_Key option in the parser configuration, you're specifying which field in your log data contains the actual timestamp. This is particularly useful when you want to preserve the original timestamp from the log source. Here's an example:

fluent-bit.conf
[PARSER]
    Name         json_parser
    Format       json
    Time_Key     timestamp

In this configuration, Fluent Bit will look for a field named "timestamp" in the JSON log data and use its value as the log entry's timestamp.

Additionally, you can use the Time_Keep option in conjunction with Time_Key:

fluent-bit.conf
[PARSER]
    Name         json_parser
    Format       json
    Time_Key     timestamp
    Time_Keep    On

The Time_Keep option, when set to "On", instructs Fluent Bit to retain the original timestamp field in the processed log entry. This can be useful if you need to reference the original timestamp later in your log processing pipeline.

Got an article suggestion? Let us know
Explore more
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github