jorgebastida / jorgebastida/awslogs

Logs from Lambda?

Open
#332 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5k
Forks
342
PR merge metrics
No merged PRs in 30d

Description

I am trying to stream log data from a lambda function and I am pretty sure that the error has somnething to do wit the fact that it doesn't like AWS convention of [$LATEST] in the log stream name.

```You've found a bug! Please, raise an issue attaching the following traceback
https://github.com/jorgebastida/awslogs/issues/new

Version: 0.14.0
Python: 3.7.3 (default, Mar 27 2019, 09:23:15)
[Clang 10.0.1 (clang-1001.0.46.3)]
boto3 version: 1.9.133
Platform: Darwin-20.1.0-x86_64-i386-64bit
Args: ['/usr/local/bin/awslogs', 'get', '/aws/lambda/Jeff_hello', '2020/12/04/[]049352026a7d4dac81b34447e63abfae', '-s1d', '--watch', '--profile', 'ami-ware
house-admin']
Config: {'aws_access_key_id': 'SENSITIVE', 'aws_secret_access_key': 'SENSITIVE', 'aws_session_token': 'SENSITIVE', 'aws_profile': 'SENSITIVE', 'aws_region': None, 'a
ws_endpoint_url': None, 'log_group_name': '/aws/lambda/Jeff_hello', 'log_stream_name': '2020/12/04/[]049352026a7d4dac81b34447e63abfae', 'filter_pattern': None, 'watc
h': True, 'watch_interval': 1, 'output_group_enabled': True, 'output_stream_enabled': True, 'output_timestamp_enabled': False, 'output_ingestion_time_enabled': False
, 'start': '1d', 'end': None, 'color': 'auto', 'query': None, 'func': 'list_logs'}

Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/awslogs/bin.py", line 179, in main
getattr(logs, options.func)()
File "/usr/local/lib/python3.7/site-packages/awslogs/core.py", line 109, in list_logs
streams = list(self._get_streams_from_pattern(self.log_group_name, self.log_stream_name))
File "/usr/local/lib/python3.7/site-packages/awslogs/core.py", line 101, in _get_streams_from_pattern
reg = re.compile('^{0}'.format(pattern))
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 234, in compile
return _compile(pattern, flags)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 286, in _compile
p = sre_compile.compile(pattern, flags)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sre_compile.py", line 764, in compile
p = sre_parse.parse(p, flags)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sre_parse.py", line 930, in parse
p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0)
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sre_parse.py", line 426, in _parse_sub
not nested and not items))
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/sre_parse.py", line 532, in _parse
source.tell() - here)
re.error: unterminated character set at position 12```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in awslogs/core.py at _get_streams_from_pattern, where the traceback shows the log stream name is compiled as a regular expression. Reproduce the failure with the reported stream name containing [] and verify that fetching the Lambda logs no longer raises the unterminated character-set error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.