awswrangler.cloudwatch.filter_log_events¶
- awswrangler.cloudwatch.filter_log_events(log_group_name: str, log_stream_name_prefix: str | None = None, log_stream_names: list[str] | None = None, filter_pattern: str | None = None, start_time: datetime | None = None, end_time: datetime | None = None, boto3_session: Session | None = None) DataFrame ¶
List log events from the specified log group. The results are returned as Pandas DataFrame.
Note
Cannot call
filter_log_events
with bothlog_stream_names
andlog_stream_name_prefix
.- Parameters:
log_group_name (
str
) – The name of the log group.log_stream_name_prefix (
str
|None
) – Filters the results to include only events from log streams that have names starting with this prefix.log_stream_names (
list
[str
] |None
) – Filters the results to only logs from the log streams in this list.filter_pattern (
str
|None
) – The filter pattern to use. If not provided, all the events are matched.start_time (
datetime
|None
) – Events with a timestamp before this time are not returned.end_time (
datetime
|None
) – Events with a timestamp later than this time are not returned.boto3_session (
Session
|None
) – The default boto3 session will be used if boto3_session isNone
.
- Return type:
DataFrame
- Returns:
Result as a Pandas DataFrame.
Examples
Get all log events from log group ‘aws_sdk_pandas_log_group’ that have log stream prefix ‘aws_sdk_pandas_log_stream’
>>> import awswrangler as wr >>> df = wr.cloudwatch.filter_log_events( ... log_group_name="aws_sdk_pandas_log_group", ... log_stream_name_prefix="aws_sdk_pandas_log_stream", ... )
Get all log events contains ‘REPORT’ from log stream ‘aws_sdk_pandas_log_stream_one’ and ‘aws_sdk_pandas_log_stream_two’ from log group ‘aws_sdk_pandas_log_group’
>>> import awswrangler as wr >>> df = wr.cloudwatch.filter_log_events( ... log_group_name="aws_sdk_pandas_log_group", ... log_stream_names=["aws_sdk_pandas_log_stream_one","aws_sdk_pandas_log_stream_two"], ... filter_pattern="REPORT", ... )