Boto3 pagination token returns incorrect logs

Viewed 16

I wrote an api that would fetch logs from cloudwatch and return a token if there were still more to be fetched when I return the next token that was provided from the previous response I get the wrong logs fetched. I suspect that it might be because the api doesn't read the token because the returned logs are the most recent. I'm not sure exactly why it does this.

here is the pagination API:

 if start_token:
        response_iterator = paginator.paginate(
            logGroupName=log_group,
            filterPattern=query,
            PaginationConfig={"MaxItems": page_size, "StartingToken": start_token},
        )
    else:
        response_iterator = paginator.paginate(
            logGroupName=log_group,
            startTime=int_start_time,
            endTime=int_end_time,
            filterPattern=query,
            PaginationConfig={"MaxItems": page_size},
        )

the returned token from the previous response is start_token

0 Answers
Related