maxbanton / cwh

Amazon Web Services CloudWatch Logs Handler for Monolog library
MIT License
417 stars 84 forks source link

Log events in a single PutLogEvents request must be in chronological order #69

Closed KiNgMaR closed 4 years ago

KiNgMaR commented 5 years ago

Re-creating a new entry for the problem explained in #32, because the fix there had to be reverted and the exception is still occurring. I'm also investigating libraries for other languages for potential fixes.

Timestamps in my case look e.g. like this:

1568894292321.3
1568894292321.3
1568894292322.5
1568894292322.5
1568894292322.5
1568894292322.5
1568894292323.6
1568894292323.6
1568894292323.6
1568894292323.6
1568894292324.7
1568894292324.7
1568894292324.7
KiNgMaR commented 5 years ago

Two findings so far:

Possible solution, seeing that this might be an AWS-specific problem:

Workarounds:

KiNgMaR commented 5 years ago

I wasn't able to figure out exactly why Symfony (or Monolog) would submit entries not already sorted chronologically, but in the end it does not matter: the requirement for submitting entries chronologically sorted seems to be a peculiarity of AWS CloudWatch logs, and therefore treating that issue within a CloudWatch-specific library seems appropriate.

I opened a PR with sort logic implemented which (at least for me) fixes the problem. Feedback appreciated :)