我有一个PHP工作者,我可以在那里记录事件到AWS.不幸的是,当我尝试提交它时,我收到以下错误.
InvalidSequenceTokenException在" https://logs.eu-west-1.amazonaws.com " 上执行"PutLogEvents"时出错; AWS HTTP错误:客户端错误:
POST https://logs.eu-west-1.amazonaws.com
导致400 Bad Request
响应:{"_ _ type":"InvalidSequenceTokenException","expectedSequenceToken":"999999999999990356407851919528174(截断...)InvalidSequenceTokenException(client):给定的sequenceToken无效.下一个预期的sequenceToken是: 495599999999988500356407851919528174642 - {"_ _ type":"InvalidSequenceTokenException","expectedSequenceToken":"495573099999999900356407851919528174642","message":"给定的sequenceToken无效.下一个预期的sequenceToken是: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" ] ] ]);
Mircea.. 7
http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
您必须在请求中包含序列标记.如果您没有,则必须使用describeLogStreams(http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogStreams.html)来获取流序列.
当您调用putLogEvents时,您将在响应中获得nextToken.您还必须为其他人推送到流并使nextToken无效的情况做好准备.(在这种情况下,您需要再次描述流以获取更新的令牌).
http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
您必须在请求中包含序列标记.如果您没有,则必须使用describeLogStreams(http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_DescribeLogStreams.html)来获取流序列.
当您调用putLogEvents时,您将在响应中获得nextToken.您还必须为其他人推送到流并使nextToken无效的情况做好准备.(在这种情况下,您需要再次描述流以获取更新的令牌).