diff --git a/moto/logs/models.py b/moto/logs/models.py index cc0d21d47..448d3dec1 100644 --- a/moto/logs/models.py +++ b/moto/logs/models.py @@ -125,6 +125,9 @@ class LogStream: return events_page, get_paging_token_from_index(back_index, True), get_paging_token_from_index(next_index) def filter_log_events(self, log_group_name, log_stream_names, start_time, end_time, limit, next_token, filter_pattern, interleaved): + if filter_pattern: + raise NotImplementedError('filter_pattern is not yet implemented') + def filter_func(event): if start_time and event.timestamp < start_time: return False diff --git a/tests/test_logs/test_logs.py b/tests/test_logs/test_logs.py index 22e7edeec..3faa588ec 100644 --- a/tests/test_logs/test_logs.py +++ b/tests/test_logs/test_logs.py @@ -128,6 +128,34 @@ def test_filter_logs_interleaved(): resulting_event['timestamp'].should.equal(original_message['timestamp']) resulting_event['message'].should.equal(original_message['message']) + +@mock_logs +def test_filter_logs_raises_if_filter_pattern(): + 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 + ) + with assert_raises(NotImplementedError): + conn.filter_log_events( + logGroupName=log_group_name, + logStreamNames=[log_stream_name], + filterPattern='{$.message = "hello"}', + ) + + @mock_logs def test_put_retention_policy(): conn = boto3.client('logs', 'us-west-2') @@ -142,6 +170,7 @@ def test_put_retention_policy(): response = conn.delete_log_group(logGroupName=log_group_name) + @mock_logs def test_delete_retention_policy(): conn = boto3.client('logs', 'us-west-2')