Skip to content

timestamp_format is ignored #2000

Open

Description

@davidjmemmett

Describe the bug
Given standard high-precision syslog format and config: "timestamp_format": "%Y-%m-%dT%H:%M:%S.%f+00:00" and "trim_timestamp": true, the timestamp in CloudWatch Logs differs from the timestamp in the log message, and the timestamp isn't trimmed.

Steps to reproduce

                    {
                        "file_path": "/var/log/syslog",
                        "log_group_class": "STANDARD",
                        "log_group_name": "syslog",
                        "log_stream_name": "{instance_id}",
                        "retention_in_days": 30,
                        "timestamp_format": "%Y-%m-%dT%H:%M:%S.%f+00:00",
                        "trim_timestamp": true
                    },

What did you expect to see?
No timestamp in the Message field and the correct timestamp in the Timestamp field

What did you see instead?
The correct timestamp in the Message field, and an incorrect timestamp in the Timestamp field

What version did you use?
CWAgent/1.300064.0b1337 (go1.25.5; linux; arm64)

What config did you use?
As above

Environment
Ubuntu 24.04.2 LTS

Additional context

Image

Activity

  1. davidjmemmett commented on Feb 4, 2026

    @davidjmemmett
    Author

    To confirm, I ensured that the time format is correct, as per the docs and the standard strptime/strftime functions:

    >>> datetime.strptime("2026-02-04T11:27:44.945314+00:00", "%Y-%m-%dT%H:%M:%S.%f+00:00")
    datetime.datetime(2026, 2, 4, 11, 27, 44, 945314)
    
  2. davidjmemmett commented on Feb 4, 2026

    @davidjmemmett
    Author

    The generated TOML config file contains the following lines, which appears to miss the dot before the high-precision timestamp in the timestamp_regex:

          timestamp_layout = ["2006-01-_2T15:04:05.000+00:00", "2006-1-_2T15:04:05.000+00:00"]
          timestamp_regex = "(\\d{4}-\\s{0,1}\\d{1,2}-\\s{0,1}\\d{1,2}T\\d{2}:\\d{2}:\\d{2}(\\d{1,9})+00:00)"
    
  3. davidjmemmett commented on Feb 4, 2026

    @davidjmemmett
    Author

    After some messing about, I've tweaked the expression in RegEx101 in order to make it match: https://regex101.com/r/QI1Xe8/1

    The new expression: (\d{4}-\s{0,1}\d{1,2}-\s{0,1}\d{1,2}T\d{2}:\d{2}:\d{2}\.(\d{1,9})\+00:00)

    So I believe the original expression is missing the \. between the seconds and the microseconds, as well as escaping on the \+ before the hard-coded timezone.

  4. varunch77 commented on Feb 6, 2026

    @varunch77
    Member

    Hi David, thanks for deep diving on this issue and bringing this to our attention. I will bring this up to my team for further discussion.

  5. jefchien commented on Feb 9, 2026

    @jefchien
    Contributor

    Tested the configuration and it gets generated with the escaped .. The issue is that the agent doesn't escape the +.

          timestamp_layout = ["2006-01-_2T15:04:05..000+00:00", "2006-1-_2T15:04:05..000+00:00"]
          timestamp_regex = "(\\d{4}-\\s{0,1}\\d{1,2}-\\s{0,1}\\d{1,2}T\\d{2}:\\d{2}:\\d{2}\\.(\\d{1,9})+00:00)"
    
  6. davidjmemmett commented on Feb 12, 2026

    @davidjmemmett
    Author

    Hi @jefchien @varunch77 ,
    I've got AWS CloudWatch Agent installed via a AWS EC2 ImageBuilder recipe - is there an easy way for me to update it to an alpha build containing this fix to verify?
    Cheers,
    David

  7. davidjmemmett commented on Feb 20, 2026

    @davidjmemmett
    Author

    Any progress @jefchien @varunch77 ?

  8. jefchien commented on Mar 19, 2026

    @jefchien
    Contributor

    Hi @davidjmemmett,

    Sorry for the delay (need to look at GitHub notifications more). We don't have an alpha build that is publicly available. How do you install the CloudWatch agent in your ImageBuilder recipe? Is it from S3 or the Amazon Linux yum repos?

  9. davidjmemmett commented on Mar 19, 2026

    @davidjmemmett
    Author

    Hi @davidjmemmett,

    Sorry for the delay (need to look at GitHub notifications more). We don't have an alpha build that is publicly available. How do you install the CloudWatch agent in your ImageBuilder recipe? Is it from S3 or the Amazon Linux yum repos?

    It's AWS' recipe & it's on Ubuntu, so I've no idea what it does under the hood.

  10. jefchien commented on Mar 19, 2026

    @jefchien
    Contributor

    Took a look at the EC2 Image builder component (amazon-cloudwatch-agent-linux). Looks like it downloads the CloudWatch agent from the regional S3 bucket.

    https://s3.$REGION.amazonaws.com/amazoncloudwatch-agent-$REGION/$OS/$TYPE/latest/amazon-cloudwatch-agent.$EXTENSION
    
  11. davidjmemmett commented on Mar 20, 2026

    @davidjmemmett
    Author

    Took a look at the EC2 Image builder component (amazon-cloudwatch-agent-linux). Looks like it downloads the CloudWatch agent from the regional S3 bucket.

    https://s3.$REGION.amazonaws.com/amazoncloudwatch-agent-$REGION/$OS/$TYPE/latest/amazon-cloudwatch-agent.$EXTENSION
    

    I'm just including the component ARN: arn:aws:imagebuilder:eu-west-2:aws:component/amazon-cloudwatch-agent-linux/1.0.1/1

  12. davidjmemmett commented on Mar 24, 2026

    @davidjmemmett
    Author

    Hi @jefchien,
    Any idea when I can use a newer build?

  13. jefchien commented on Apr 2, 2026

    @jefchien
    Contributor

    Hi @davidjmemmett,

    The CloudWatch Agent follows a regular release cycle. You can check the release tags (https://github.com/aws/amazon-cloudwatch-agent/tags) to confirm which release includes the fix.

    Once a release is built, it is rolled out progressively across all distribution channels (S3, SSM, container images, Amazon Linux repos, EKS add-on, etc.), which can take several weeks to complete across all regions and channels. This means there can be a gap between when a release is tagged and when updated artifacts are available.

    We don't publish fixed timelines for individual patches.

  14. davidjmemmett commented on Apr 7, 2026

    @davidjmemmett
    Author

    Hi,

    I tested the version released last night and it doesn't seem to have resolved the issue...

    CWAgent/1.300064.1b1344 (go1.25.6; linux; arm64)

    Cheers,
    David

  15. jefchien commented on Apr 9, 2026

    @jefchien
    Contributor

    The fix you're looking for 9a85a39 is part of v1.300065.0+ as shown by the tags. Those versions are not available yet.

  16. jefchien commented on Apr 22, 2026

    @jefchien
    Contributor

    @davidjmemmett The fix has been released as part of v1.300066.1.

  17. davidjmemmett commented on Apr 24, 2026

    @davidjmemmett
    Author

    Hi @jefchien I have installed AmazonCloudWatchAgent CWAgent/1.300066.1b1374 and now it's not sending any logs to CloudWatch at all. There's nothing in /var/log/amazon/amazon-cloudwatch-agent/amazon-cloudwatch-agent.log suggesting any issues either.

  18. davidjmemmett commented on Apr 24, 2026

    @davidjmemmett
    Author

    Hi @jefchien I have installed AmazonCloudWatchAgent CWAgent/1.300066.1b1374 and now it's not sending any logs to CloudWatch at all. There's nothing in /var/log/amazon/amazon-cloudwatch-agent/amazon-cloudwatch-agent.log suggesting any issues either.

    Ignore this, I found some troubleshooting in the AWS docs and it seems to be working. I'll keep testing and close this issue when I have verified that everything is working as expected.

    Thanks for your help.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions