cwh: InvalidSequenceTokenException
Hi,
I am using your cloud watch handler for symfony. I rolled out the cwh in multiple environments (dev, staging, demo, prod, … ) and are now experiencing something odd after a couple of successfull pushes:
[Aws\CloudWatchLogs\Exception\CloudWatchLogsException]
Error executing "PutLogEvents" on "https://logs.eu-central-1.amazonaws.com"; AWS HTTP error: Client error response [url] https://logs.eu-central-
1.amazonaws.com [status code] 400 [reason phrase] Bad Request InvalidSequenceTokenException (client): The given sequenceToken is invalid. The nex
t expected sequenceToken is: 49578481559872967104658335510065862421249324983057912274 - {"__type":"InvalidSequenceTokenException","expectedSequen
ceToken":"49578481559872967104658335510065862421249324983057912274","message":"The given sequenceToken is invalid. The next expected sequenceToke
n is: 49578481559872967104658335510065862421249324983057912274"}
This is my configuration:
class: Maxbanton\Cwh\Handler\CloudWatch
arguments:
- "@cloudwatch_client"
- "%elasticbeanstalk_app%" # groupName
- "%kernel.environment%" # streamName
- 30 # retentionDays
- 5 # logsInBatch
- { mytag: "tag" } # tags
- NOTICE # logLevel
Is it maybe an issue, that I chose batchsize of 5?
It is neccesary to use use different access key / secret for different environment?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 19 (8 by maintainers)
Commits related to this issue
- Refresh with fresh sequence token (#56) * Refresh with fresh sequence token * reformats phpdoc to fit within 140 characters — committed to maxbanton/cwh by mstovicek 6 years ago
For anyone looking for a workaround for this I forked with some retry code.
Overview of changes:
$tokenRetries
parameter to specify how many times you want to retry sending the buffer. Defaults to 0 (existing behavior)invalidSequenceToken
exception typesend
will try to get a new token making an api call usingdescribeLogStreams
and then retry itself if the number of attempts is less than$tokenRetries
@klausbreyer It seems that is not straight forward solution to this ? I could recommend alternative solution such as elastic stack.
@klausbreyer You can use this fork but please be aware that this is just a temporary solution and you will lose some logs
https://github.com/banstola/cwh