diff --git a/moto/logs/models.py b/moto/logs/models.py index 6ff7f93bf..3ae697a27 100644 --- a/moto/logs/models.py +++ b/moto/logs/models.py @@ -184,7 +184,7 @@ class LogGroup: events += stream.filter_log_events(log_group_name, log_stream_names, start_time, end_time, limit, next_token, filter_pattern, interleaved) if interleaved: - events = sorted(events, key=lambda event: event.timestamp) + events = sorted(events, key=lambda event: event['timestamp']) if next_token is None: next_token = 0 diff --git a/tests/test_logs/test_logs.py b/tests/test_logs/test_logs.py index 0139723c9..a9a7f5260 100644 --- a/tests/test_logs/test_logs.py +++ b/tests/test_logs/test_logs.py @@ -85,4 +85,32 @@ def test_put_logs(): logStreamName=log_stream_name ) events = res['events'] - events.should.have.length_of(2) \ No newline at end of file + events.should.have.length_of(2) + + +@mock_logs +def test_filter_logs_interleaved(): + conn = boto3.client('logs', 'us-west-2') + log_group_name = 'dummy' + log_stream_name = 'stream' + conn.create_log_group(logGroupName=log_group_name) + conn.create_log_stream( + logGroupName=log_group_name, + logStreamName=log_stream_name + ) + messages = [ + {'timestamp': 0, 'message': 'hello'}, + {'timestamp': 0, 'message': 'world'} + ] + conn.put_log_events( + logGroupName=log_group_name, + logStreamName=log_stream_name, + logEvents=messages + ) + res = conn.filter_log_events( + logGroupName=log_group_name, + logStreamNames=[log_stream_name], + interleaved=True, + ) + events = res['events'] + events.should.have.length_of(2)