maxbanton / cwh

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

Getting error: The batch of log events in a single PutLogEvents request cannot span more than 24 hours #96

Closed webkod3r closed 2 years ago

webkod3r commented 3 years ago

Lumen version: 5.6 package version: v1.1.14

Recently I started getting this error while running my lumen application: The batch of log events in a single PutLogEvents request cannot span more than 24 hours.

Eexception 'Aws\CloudWatchLogs\Exception\CloudWatchLogsException' with message 'Error executing "PutLogEvents" on "https://logs.us-east-1.amazonaws.com"; AWS HTTP error: Client error: `POST https://logs.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response:
{"__type":"InvalidParameterException","message":"The batch of log events in a single PutLogEvents request cannot span mo (truncated...)
 InvalidParameterException (client): The batch of log events in a single PutLogEvents request cannot span more than 24 hours. - {"__type":"InvalidParameterException","message":"The batch of log events in a single PutLogEvents request cannot span more than 24 hours."}'

GuzzleHttp\Exception\ClientException: Client error: `POST https://logs.us-east-1.amazonaws.com` resulted in a `400 Bad Request` response:
{"__type":"InvalidParameterException","message":"The batch of log events in a single PutLogEvents request cannot span mo (truncated...)
 in /application/path/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113
Stack trace:
...

Is anyone familiar with this type of error? Does this error mean the log stream was pushing logs for more than 24 hours? Can this package handle log streams that old?

Thanks for your help.

roborourke commented 2 years ago

Also seeing this though it appears to be incredibly rare. Digging into why this might occur.

lucasantarella commented 2 years ago

Also getting this, but it's related to when there are few enough requests that it doesn't trigger the batch to be sent until after 24 hours.

I know it is explicitly written in the documentation that this is the case (phpdoc on the method) but maybe we should have some way to flush the batch after a certain period?

jackwakefield commented 2 years ago

This is fixed by https://github.com/maxbanton/cwh/pull/107

cbulgariu commented 2 years ago

This is fixed by #107

do you know when it will be merged ?

maxbanton commented 2 years ago

Hi guys, it's a little bit hard to maintain war-work-life balance, so sorry for delay. PR is already merged and new version v2.0.3 has been published. Please test it an let me know if everything is ok. Thanks.

roborourke commented 2 years ago

Oh man, thanks so much @maxbanton. Will work off a fork rather than put any undue additional pressure on you if there are future issues that need an urgent fix.

webkod3r commented 2 years ago

Thanks @maxbanton and sorry to hear that.