parse fractional-second ISO-8601 timestamps in syslog parser#21
parse fractional-second ISO-8601 timestamps in syslog parser#21HrachShah wants to merge 1 commit into
Conversation
SyslogParser.PATTERNS[1] already accepts timestamps with optional
fractional seconds and an optional Z or numeric offset:
\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?
But _parse_timestamp only knew about:
'%Y-%m-%dT%H:%M:%S.%f' (no offset)
'%Y-%m-%dT%H:%M:%S%z' (no fractional)
So an input like '2025-03-20T10:15:32.123Z' or
'2025-03-20T10:15:32.123+02:00' was matched by the regex and
can_parse() returned True, but parse() then set timestamp=None and
the time_distribution, source/time-range reports, and start-time/
end-time filters all silently lost those entries. This format is
the default for rsyslog with RFC 5424 templates and for journald
exporters, so it is by far the most common modern syslog format.
Add '%Y-%m-%dT%H:%M:%S.%f%z' to the format list and normalize the
trailing 'Z' to '+00:00' before passing the string to strptime.
Two new tests pin the behavior for both the Z suffix and the
numeric offset variants.
There was a problem hiding this comment.
Sorry @HrachShah, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
Warning Review limit reached
More reviews will be available in 41 minutes and 55 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses rolling per-developer review limits. Reviews become available again as older review attempts age out of the rolling limit window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
SyslogParser.PATTERNS[1] already accepts timestamps with optional
fractional seconds and an optional Z or numeric offset:
\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:.\d+)?(?:Z|[+-]\d{2}:\d{2})?
But _parse_timestamp only knew about:
'%Y-%m-%dT%H:%M:%S.%f' (no offset)
'%Y-%m-%dT%H:%M:%S%z' (no fractional)
So an input like '2025-03-20T10:15:32.123Z' or
'2025-03-20T10:15:32.123+02:00' was matched by the regex and
can_parse() returned True, but parse() then set timestamp=None and
the time_distribution, source/time-range reports, and start-time/
end-time filters all silently lost those entries. This format is
the default for rsyslog with RFC 5424 templates and for journald
exporters, so it is by far the most common modern syslog format.
Add '%Y-%m-%dT%H:%M:%S.%f%z' to the format list and normalize the
trailing 'Z' to '+00:00' before passing the string to strptime.
Two new tests pin the behavior for both the Z suffix and the
numeric offset variants.