Closed agoyburu closed 1 month ago
Thanks for reaching out. The filter_log_events command makes a call to the underlying FilterLogEvents API, so this issue is really about the API behavior. If you add boto3.set_stream_logger('')
to your script, then you can see the API request/response.
The reason you're getting a nextToken
but not events is likely because the API is returning a max limit of results and there are no events matching your filter in that response. As an alternative, I recommend using the paginator to automatically paginate through responses: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/logs/paginator/FilterLogEvents.html
(For more info on paginators please refer to this documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/paginators.html)
Greetings! It looks like this issue hasn’t been active in longer than five days. We encourage you to check if this is still an issue in the latest release. In the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or upvote with a reaction on the initial post to prevent automatic closure. If the issue is already closed, please feel free to open a new one.
Describe the bug
When calling
filter_log_events
using CloudWatchLogs client, thenextToken
key is always coming with a token instead ofnull
even though there are no results.Expected Behavior
nextToken
should be null whenevents
is empty.Current Behavior
events
returns an empty list butnextToken
is not nullReproduction Steps
filter_log_events
withlogGroupName, filterPattern, startTime, endTime
nextToken
.Possible Solution
I don't have a possible solution but a workaround could be to also check the results if that is empty, just ignore the nextToken
Additional Information/Context
The odd thing is that this is only happening with one AWS account so far.
To do the filtering, we first call
describe_log_groups
to get the list of log groups and then perform the filtering for each group.Here are the some of the arguments I used:
And here some actual responses from the
filter_log_events
First call
Second call
SDK version used
boto3==1.34.80
Environment details (OS name and version, etc.)
MacOS Sonoma 14.6.1 (23G93), Ubuntu 22.04 docker image