当前位置:  开发笔记 > 编程语言 > 正文

AWS-CloudWatch:InvalidSequenceTokenException

如何解决《AWS-CloudWatch:InvalidSequenceTokenException》经验,为你挑选了1个好方法。

我有一个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无效的情况做好准备.(在这种情况下,您需要再次描述流以获取更新的令牌).



1> Mircea..:

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无效的情况做好准备.(在这种情况下,您需要再次描述流以获取更新的令牌).

推荐阅读
依然-狠幸福
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有