amazon-cloudwatch-agent icon indicating copy to clipboard operation
amazon-cloudwatch-agent copied to clipboard

fix: no dot when converting %f to timestamp layout

Open manger opened this issue 2 years ago • 5 comments

Description of the issue

In a timestamp format, %f (fraction of seconds) represents the digits, not including the decimal mark (point or comma). So when converting a format to a layout, %f should be replaced with 000.

For example, the format "%H:%M:%S.%f" should be converted to the layout "15:04:05.000". Currently, the code incorrectly converts that format to "15:04:05..000" (note the two dots).

The capturing group for %f in TimeFormatRexMap looks wrong as no other mapping uses a capturing group.

Description of changes

%f in a format is mapped to "000", instead of ".000", in a layout.

License

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Tests

None.

Requirements

Before commit the code, please do the following steps.

  1. Run make fmt and make fmt-sh
  2. Run make linter

manger avatar Mar 15 '23 07:03 manger

Hi @manger , Thanks for the great contribution on this problem and it would be better to show what have you done by testing with CWA: before and after so we would have confidence in delivering it and ensure there is no regression. Will give a more detail review later on.

khanhntd avatar Mar 15 '23 14:03 khanhntd

This PR was marked stale due to lack of activity.

github-actions[bot] avatar Mar 23 '23 00:03 github-actions[bot]

@manger can you give a reproducible example for us to validate against?

SaxyPandaBear avatar Apr 11 '23 13:04 SaxyPandaBear

@manger can you give a reproducible example for us to validate against?

The default timestamp format for Log4J2 %d produces timestamps such as 2006-01-02 22:04:05,000 or 2012-11-02 14:34:02,123 with fraction-of-seconds to millisecond precision, and a decimal comma.

That is an example that doesn't work without a fix.

manger avatar Apr 14 '23 03:04 manger

This PR was marked stale due to lack of activity.

github-actions[bot] avatar Apr 22 '23 00:04 github-actions[bot]