-
Notifications
You must be signed in to change notification settings - Fork 110
[Release-3.14.1][Bug] Fix incorrect timestamp parsing for chef-client.log in CloudWatch Agent #3061
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Release-3.14.1][Bug] Fix incorrect timestamp parsing for chef-client.log in CloudWatch Agent #3061
Conversation
The CloudWatch Agent configuration was using the 'default' timestamp format (%Y-%m-%d %H:%M:%S,%f) for chef-client.log, but Chef/Cinc outputs timestamps in ISO 8601 format: [YYYY-MM-DDTHH:MM:SS+TZ]. This mismatch caused CloudWatch to fail parsing timestamps, resulting in log lines being associated with incorrect timestamps (often shifted by hours), which significantly complicated root cause analysis during incident investigations. Changes: - Add new 'chef' timestamp format: [%Y-%m-%dT%H:%M:%S (Note: CloudWatch Agent's %z only supports timezone without colon like -0700, but Chef outputs +02:00 format. We match up to seconds and let CloudWatch handle the rest.) - Update chef-client.log configuration to use the new 'chef' format Reference: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html\#CloudWatch-Agent-Configuration-File-Logssection
9e16558 to
f415f1d
Compare
|
Can you add more details on how this was tested? |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-3.14 #3061 +/- ##
=============================================
Coverage 75.22% 75.22%
=============================================
Files 24 24
Lines 2446 2446
=============================================
Hits 1840 1840
Misses 606 606
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Done |
| "default": "%Y-%m-%d %H:%M:%S,%f", | ||
| "bracket_default": "[%Y-%m-%d %H:%M:%S]", | ||
| "slurm": "%Y-%m-%dT%H:%M:%S.%f", | ||
| "chef": "[%Y-%m-%dT%H:%M:%S", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing final square bracket?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the description this is intentional:
(Note: CloudWatch Agent's %z only supports timezone without colon like -0700, but Chef outputs +02:00 format. We only match up to seconds and let CloudWatch handle the rest.)
I'm ok with the current approach. However, did you check if chef allows to write the offset in the format accepted by CW?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have synced, that we do have a way to customize the chef timestamp format, but it doesn't worth the effort. So we will accept the current approach.
CHANGELOG.md
Outdated
| - Open MPI: openmpi40-aws-4.1.7-2 and openmpi50-aws-5.0.8-11 | ||
|
|
||
| **BUG FIXES** | ||
| - Fix incorrect timestamp parsing for chef-client.log in CloudWatch Agent configuration. The timestamp format now correctly matches Chef's output format `[YYYY-MM-DDTHH:MM:SS+TZ]`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can remove the detail about the format because it is a low level detail.
I'd limit the line to
Fix incorrect timestamp parsing for chef-client.log in CloudWatch Agent configuration.
Description of changes
The CloudWatch Agent configuration was using the
defaulttimestamp format (%Y-%m-%d %H:%M:%S,%f) for chef-client.log, but Chef/Cinc outputs ISO 8601 timestamps in format:[YYYY-MM-DDTHH:MM:SS+TZ].This mismatch caused CloudWatch to fail parsing timestamps, resulting in log lines being associated with incorrect timestamps.
[%Y-%m-%dT%H:%M:%S(Note: CloudWatch Agent's %z only supports timezone without colon like -0700, but Chef outputs +02:00 format. We only match up to seconds and let CloudWatch handle the rest.)
Tests
Manually tests done, I create a cluster and export the cluster logs. Now in the chef-client log, I can see CW timestamp matches chef timestamp, e.g.:
Reference
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html#CloudWatch-Agent-Configuration-File-Logssection
Expand
CloudWatch agent configuration file: Logs sectionsection:Checklist
developadd the branch name as prefix in the PR title (e.g.[release-3.6]).Please review the guidelines for contributing and Pull Request Instructions.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.