我有一個PHP工作人員,我在AWS上記錄事件可以觀看。 不幸的是,當我嘗試提交時出現以下錯誤。AWS-CloudWatch:InvalidSequenceTokenException
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"}
,這是我的代碼
$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"
]
]
]);
謝謝你是對的。但調用describeLogStream不會返回下一個序列!請更新您的答案,以便我可以接受它。它實際上是 – Moussawi7
。我看你的迴應,它包含一個LogStreams對象的數組:http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_LogStream.html UploadSequenceToken在響應中是你需要傳入的。 – Mircea
謝謝@thext,你是完全正確的。 – Moussawi7