I have a php worker where i log events to AWS could watch. Unfortunately i got the following error when i try to submit it.
InvalidSequenceTokenException Error executing "PutLogEvents" on "https://logs.eu-west-1.amazonaws.com"; AWS HTTP error: Client error:
POST https://logs.eu-west-1.amazonaws.com
resulted in a400 Bad Request
response: {"__type":"InvalidSequenceTokenException","expectedSequenceToken":"999999999999990356407851919528174 (truncated...) InvalidSequenceTokenException (client): The given sequenceToken is invalid. The next expected sequenceToken is: 495599999999988500356407851919528174642 - {"__type":"InvalidSequenceTokenException","expectedSequenceToken":"495573099999999900356407851919528174642","message":"The given sequenceToken is invalid. The next expected sequenceToken is: 495579999999900356407851919528174642"}
and this is my code
$date = new DateTime();
$instance= = new CloudWatchLogsClient([
'region' => 'eu-west-1',
'version' => 'latest',
'credentials' => [
'key' => 'XXX',
'secret' => 'XXXX'
]
]);
$instance->putLogEvents([
'logGroupName' => "WorkerLog",
'logStreamName' => "log",
'logEvents' => [
[
'timestamp' => $date->getTimestamp(),
'message' => "test log"
]
]
]);