filter_log_events
async
¶
filter_log_events(
*,
config_overrides: Optional[AsyncCloudWatchLogsClientConfig] = None,
log_group_name: Optional[LogGroupName] = None,
log_group_identifier: Optional[LogGroupIdentifier] = None,
log_stream_names: Optional[InputLogStreamNames] = None,
log_stream_name_prefix: Optional[LogStreamName] = None,
start_time: Optional[Timestamp] = None,
end_time: Optional[Timestamp] = None,
filter_pattern: Optional[FilterPattern] = None,
next_token: Optional[NextToken] = None,
limit: Optional[EventsLimit] = None,
start_from_head: Optional[StartFromHead] = None,
interleaved: Optional[Interleaved] = None,
unmask: Optional[Unmask] = None,
) -> FilterLogEventsResponse
Lists log events from the specified log group. You can list all the log events or filter the results using one or more of the following:
-
A filter pattern
-
A time range
-
The log stream name, or a log stream name prefix that matches multiple log streams
You must have the logs:FilterLogEvents permission to perform this operation.
You can specify the log group to search by using either logGroupIdentifier or logGroupName. You must include one of these two parameters, but you can't include both.
FilterLogEvents is a paginated operation. Each page returned can contain up to 1 MB of log events or up to 10,000 log events. A returned page might only be partially full, or even empty. For example, if the result of a query would return 15,000 log events, the first page isn't guaranteed to have 10,000 log events even if they all fit into 1 MB.
Partially full or empty pages don't necessarily mean that pagination is finished. If the results include a nextToken, there might be more log events available. You can return these additional log events by providing the nextToken in a subsequent FilterLogEvents operation. If the results don't include a nextToken, then pagination is finished.
Specifying the limit parameter only guarantees that a single page doesn't return more log events than the specified limit, but it might return fewer events than the limit. This is the expected API behavior.
The returned log events are sorted by event timestamp, the timestamp when the event was ingested by CloudWatch Logs, and the ID of the PutLogEvents request. By default, the events are returned in ascending timestamp order (oldest first). To return events in descending timestamp order (newest first), set the startFromHead parameter to false.
If you are using CloudWatch cross-account observability, you can use this operation in a monitoring account and view data from the linked source accounts. For more information, see CloudWatch cross-account observability.
If you are using log transformation, the FilterLogEvents operation returns only the original versions of log events, before they were transformed. To view the transformed versions, you must use a CloudWatch Logs query.
Parameters:
-
log_group_name(Optional[LogGroupName], default:None) –The name of the log group to search.
You must include either
logGroupIdentifierorlogGroupName, but not both. -
log_group_identifier(Optional[LogGroupIdentifier], default:None) –Specify either the name or ARN of the log group to view log events from. If the log group is in a source account and you are using a monitoring account, you must use the log group ARN.
You must include either
logGroupIdentifierorlogGroupName, but not both. -
log_stream_names(Optional[InputLogStreamNames], default:None) –Filters the results to only logs from the log streams in this list.
If you specify a value for both
logStreamNamesandlogStreamNamePrefix, the action returns anInvalidParameterExceptionerror. -
log_stream_name_prefix(Optional[LogStreamName], default:None) –Filters the results to include only events from log streams that have names starting with this prefix.
If you specify a value for both
logStreamNamePrefixandlogStreamNames, the action returns anInvalidParameterExceptionerror. -
start_time(Optional[Timestamp], default:None) –The start of the time range, expressed as the number of milliseconds after
Jan 1, 1970 00:00:00 UTC. Events with a timestamp before this time are not returned.Set
startTimeexplicitly to reduce the chances of empty pages in the response. -
end_time(Optional[Timestamp], default:None) –The end of the time range, expressed as the number of milliseconds after
Jan 1, 1970 00:00:00 UTC. Events with a timestamp later than this time are not returned. -
filter_pattern(Optional[FilterPattern], default:None) –The filter pattern to use. For more information, see Filter and Pattern Syntax.
If not provided, all the events are matched.
-
next_token(Optional[NextToken], default:None) –The token for the next set of events to return. (You received this token from a previous call.)
-
limit(Optional[EventsLimit], default:None) –The maximum number of events to return. The default is 10,000 events.
-
start_from_head(Optional[StartFromHead], default:None) –If the value is true, the earliest log events are returned first. If the value is false, the latest log events are returned first. The default value is true.
The
startFromHeadparameter sets the sort direction on the first request. On subsequent requests, thenextTokendetermines the sort direction. To continue paginating in the same direction, provide the returnednextToken. If you provide bothnextTokenandstartFromHead, the direction of thenextTokenis used.Setting
startFromHeadtofalseis supported only whenstartTimeis on or afterJan 1, 2024 00:00:00 UTC. A request withstartFromHeadset tofalseand astartTimebefore this date returns anInvalidParameterException. -
interleaved(Optional[Interleaved], default:None) –If the value is true, the operation attempts to provide responses that contain events from multiple log streams within the log group, interleaved in a single response. If the value is false, all the matched log events in the first log stream are searched first, then those in the next log stream, and so on.
Important As of June 17, 2019, this parameter is ignored and the value is assumed to be true. The response from this operation always interleaves events from multiple log streams within a log group.
-
unmask(Optional[Unmask], default:None) –Specify
trueto display the log event fields with all sensitive data unmasked and visible. The default isfalse.To use this operation with this parameter, you must be signed into an account with the
logs:Unmaskpermission.
Raises:
-
InvalidParameterException–A parameter is specified incorrectly.
-
ResourceNotFoundException–The specified resource does not exist.
-
ServiceUnavailableException–The service cannot complete the request.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_cloudwatch_logs/_services/async_cloud_watch_logs.py
4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 | |