Amazon CloudWatchLogs putLogEvents in PHP gives error tooOldLogEventEndIndex
I found the solution adding this line instead of time()
function of php . following this example cloudWatchLogs.
'timestamp' => round(microtime(true) * 1000),
I hope that this can help someone on the future.
Your error is telling you that the timestamp you are using is not good.
http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
From doc:
None of the log events in the batch can be more than 2 hours in the future.
None of the log events in the batch can be older than 14 days or the retention period of the log group.
If using current time and current time is correct you may be in a different time zone (that is more than 2 hours ahead of UTC). Use UTC time for events timestamp.
Cloudwatch API expects timestamp in epoch milliseconds, not seconds. Took me a while to figure that out. Thanks to the PHP snippet above.