Skip to content

parser: Add IANA time_zone support for native timestamps#11913

Merged
edsiper merged 17 commits into
masterfrom
cosmo0920-parser-timezone-iana-symbols-on-windows
Jun 4, 2026
Merged

parser: Add IANA time_zone support for native timestamps#11913
edsiper merged 17 commits into
masterfrom
cosmo0920-parser-timezone-iana-symbols-on-windows

Conversation

@cosmo0920
Copy link
Copy Markdown
Contributor

@cosmo0920 cosmo0920 commented Jun 4, 2026

This is 2nd attempt of adding IANA compatible time_zone support for system time.

This work is based on #11639 which is @arnikola's work.


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

Example config files taken from #11639 (comment):
config.conf:

[SERVICE]
    Parsers_File  parsers.conf

[INPUT]
    Name          tail
    Path          tz-example.log
    Tag           tz.test
    Parser        tz_naive
    Read_from_Head true
    Exit_On_Eof   true

[OUTPUT]
    Name          stdout
    Match         tz.test
    Format        json_lines

parsers.conf

[PARSER]
    Name         tz_naive
    Format       regex
    Regex        ^(?<ts>[^ ]+) (?<msg>.+)$
    Time_Key     ts
    Time_Format  %Y-%m-%dT%H:%M:%S
    Time_Keep    On
    Time_Strict  On
    Time_Zone    Australia/Sydney
  • Debug log output from testing the change
  • 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.

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

Documentation

  • Documentation required for this feature

Backporting

  • 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 per-parser IANA Time_Zone support so parsers convert naive timestamps using a configured zone; invalid or conflicting timezone combinations are rejected
  • Tests

    • Added unit and integration tests for IANA timezone conversion, missing-year handling, conflict validation, and platform-specific zone availability checks

cosmo0920 added 10 commits June 4, 2026 14:35
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
…p cases

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
…lookup

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
…on Windows

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 4, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 71ed0cd8-da2c-4010-baa1-20008e37fccb

📥 Commits

Reviewing files that changed from the base of the PR and between 5ebf14e and 6a16277.

📒 Files selected for processing (2)
  • include/fluent-bit/flb_parser.h
  • src/flb_parser.c
🚧 Files skipped from review as they are similar to previous changes (2)
  • include/fluent-bit/flb_parser.h
  • src/flb_parser.c

📝 Walkthrough

Walkthrough

Fluent Bit parsers now accept per-parser IANA Time_Zone, validate/load platform-specific zone data (Windows IANA→native or POSIX tzif), convert naive timestamps with the configured zone, wire Time_Zone into config/creation, update format parsers to use the new converter, and add unit/integration tests plus a CI change.

Changes

IANA Timezone Parser Feature

Layer / File(s) Summary
Timezone API and validation infrastructure
include/fluent-bit/flb_parser.h, src/flb_parser.c
Adds parser->time_zone and parser->time_zone_data, declares/implements flb_parser_tm2time_parser(), and implements Windows IANA→native mapping and POSIX tzif loading/validation.
Parser creation factory and lifecycle management
src/flb_parser.c
New exported flb_parser_create_with_time_zone(); flb_parser_create() becomes a wrapper; early validation enforces time_zone requires time_format and disallows incompatible combos; destroy frees time_zone/time_zone_data.
Configuration loading for timezone parameter
src/flb_parser.c
Loads Time_Zone from parser config sections, passes it into the new factory, and frees the loaded string on success and error paths.
Format-specific parser time conversion
src/flb_parser_json.c, src/flb_parser_logfmt.c, src/flb_parser_ltsv.c, src/flb_parser_regex.c
JSON, logfmt, LTSV, and regex parsers now call flb_parser_tm2time_parser(&tm, parser) when converting parsed struct flb_tm into time_lookup.
Time lookup conditional logic
src/flb_parser.c
Missing-year normalization and GMToff assignment use the configured IANA zone for naive timestamps; time_offset is applied only when no time_system_timezone and no time_zone are configured.
Unit test platform support and IANA tests
tests/internal/parser.c
Adds platform-aware test helpers (flb_test_tzset, env helpers, timezone availability), updates an existing midnight test, and adds multiple IANA timezone unit tests including conflict validation.
Regex parser timezone test cases
tests/internal/parser_regex.c
Adds timezone_available() helper and test_time_zone() validating flb_parser_create_with_time_zone() across zones/dates with exact epoch checks.
Integration tests for tail input with timezone
tests/integration/scenarios/in_tail/config/parsers_tail_it.conf, tests/integration/scenarios/in_tail/config/tail_parser_time_zone.yaml, tests/integration/scenarios/in_tail/tests/test_in_tail_001.py
Adds iana_timezone parser, tail integration config, and a Python integration test that conditionally verifies timestamp conversion from America/New_York to UTC.
Windows unit-test workflow adjustment
.github/workflows/call-windows-unit-tests.yaml
Removed -D FLB_WITHOUT_flb-it-parser=On from Windows unit-test CMake invocation so parser-related tests run in Windows CI.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • fluent/fluent-bit#11903: Introduces Windows↔IANA timezone conversion helpers consumed by this PR's parser timezone logic.
  • fluent/fluent-bit#11677: Modifies flb_parser_time_lookup() timezone and midnight handling; overlaps with GMToff and year-normalization changes here.

Suggested reviewers

  • edsiper
  • niedbalski
  • celalettin1286

Poem

🐰 I found a zone called New York town,

I learned its folds from files and Windows frown,
I hop through tzif and map to native names,
I nudge naive clocks to UTC frames,
Now timestamps sleep sound, no more timezone clown.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.71% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding IANA time_zone support for naive timestamps in the parser, which is clearly reflected across the entire changeset including new struct fields, functions, and comprehensive tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cosmo0920-parser-timezone-iana-symbols-on-windows

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
src/flb_parser.c

src/flb_parser.c:20:10: fatal error: 'fluent-bit/flb_info.h' file not found
20 | #include <fluent-bit/flb_info.h>
| ^~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/6a162775425a897266899b864ca5cd547815b13e-db7608c4d518ccbb/tmp/clang_command_.tmp.874190.txt
++Contents of '/tmp/coderabbit-infer/6a162775425a897266899b864ca5cd547815b13e-db7608c4d518ccbb/tmp/clang_command_.tmp.874190.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all"

... [truncated 713 characters] ...

"/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/db7608c4d518ccbb/file.o" "-x" "c"
"src/flb_parser.c" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


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.

cosmo0920 added 4 commits June 4, 2026 15:53
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 791d8faa02

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/flb_parser.c Outdated
Comment thread src/flb_parser.c Outdated
@patrick-stephens patrick-stephens changed the title parser: Add IANA time_zone support for naive timestamps parser: Add IANA time_zone support for native timestamps Jun 4, 2026
Comment thread .github/workflows/call-windows-unit-tests.yaml
cosmo0920 added 2 commits June 4, 2026 18:06
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
Comment on lines +5 to +6
http_port: ${FLUENT_BIT_HTTP_MONITORING_PORT}
parsers_file: ${PARSERS_FILE_TEST}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we can start using the defaulting options now as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. This is the first time to use parsers_file in our integration tests. So, if we'll need another part of the integration test case, we'll have to implement and use the defaulting option here.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/flb_parser.c (1)

634-649: ⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

Cache the resolved timezone at parser creation.

flb_parser_tm2time_parser() and the missing-year branch in flb_parser_time_lookup() both reload and parse the zoneinfo data for every record, while flb_parser_create_with_time_zone() only keeps the raw string. That puts blocking file I/O and TZif parsing on the parser hot path, and it means parser registration can still succeed on POSIX even when the zone file is unreadable or malformed. Resolve/parse the timezone once during creation, store the compiled state on struct flb_parser, and reuse it from both runtime paths.

Also applies to: 943-965, 1890-1905

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/flb_parser.c` around lines 634 - 649, The parser currently reparses
zoneinfo on each record; modify struct flb_parser to hold a parsed/compiled
timezone object (e.g., a tzif handle) and update
flb_parser_create_with_time_zone() to resolve and parse the zone file once
(failing creation if parsing fails), storing the compiled state on the
flb_parser; then change flb_parser_tm2time_parser() and the missing-year branch
in flb_parser_time_lookup() to use that stored tzif object instead of calling
tzif_load/tzif_tm2time each time, and ensure you free/destroy the cached tzif in
the parser destructor to avoid leaks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/flb_parser.c`:
- Around line 634-649: The parser currently reparses zoneinfo on each record;
modify struct flb_parser to hold a parsed/compiled timezone object (e.g., a tzif
handle) and update flb_parser_create_with_time_zone() to resolve and parse the
zone file once (failing creation if parsing fails), storing the compiled state
on the flb_parser; then change flb_parser_tm2time_parser() and the missing-year
branch in flb_parser_time_lookup() to use that stored tzif object instead of
calling tzif_load/tzif_tm2time each time, and ensure you free/destroy the cached
tzif in the parser destructor to avoid leaks.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 826d9b16-036e-4139-bbd2-fd91882ccaa8

📥 Commits

Reviewing files that changed from the base of the PR and between 791d8fa and 5ebf14e.

📒 Files selected for processing (2)
  • src/flb_parser.c
  • tests/internal/parser.c
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/internal/parser.c

Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
@edsiper edsiper merged commit 32233ca into master Jun 4, 2026
78 of 81 checks passed
@edsiper edsiper deleted the cosmo0920-parser-timezone-iana-symbols-on-windows branch June 4, 2026 17:05
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.

3 participants