Amazon CloudWatchLogs putLogEvents in PHP also throws error OldLogEventEndIndex

Hi guys, I am trying to put Log on amazon CloudWatchLogs as follows:

$response2 = $amzonLoger->putLogEvents([

            'logGroupName' => 'myGroup',
            'logStreamName' => 'myStream',
            'logEvents' => [
                [
                    'timestamp' => time(),
                    'message' => 'message'
                ],
            ],
            'sequenceToken' => lastToken,
        ]);
        var_dump($response2);

but I always have the answer:

bject(Guzzle\Service\Resource\Model)#289 (2) { ["structure":protected]=> NULL ["data":protected]=> array(2) { ["nextSequenceToken"]=> string(56) "495401145812734324234234236420825819917076850" ["rejectedLogEventsInfo"]=> array(1) { ["tooOldLogEventEndIndex"]=> int(1) } } }

can help me understand what ["rejectLogEventsInfo"] => array (1) {["tooOldLogEventEndIndex"] => int (1) means, I will be very grateful for the help.

+8
source share
3 answers

Your error says that the timestamp you are using is not suitable.

http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html

From the doc doc:

2 .
14 .

, ( , 2 UTC). UTC .

0

ok, , , time() php. cloudWatchLogs.

'timestamp' =>  round(microtime(true) * 1000),

, - .

+13

Cloudwatch API , . , . PHP.

0

Source: https://habr.com/ru/post/1609705/


All Articles