awslogs
awslogs copied to clipboard
error report when fetching log group with --query=message and JSON in log output
running on macosx, installed awslogs from homebrew, i hit an error when trying to grab log data. the log fetching works when i don't specify --query parameter, but i really want to get rid of all the noise and just get the 'message' field of the log
awslogs version 0.14.0
Command i ran:
awslogs get /aws/lambda/mylambda --query=message --start='Sept 18 22:10:00 UTC 2020' --end='Sept 18 22:20:00 UTC 2020'
I see an error with parsing JSON. I'm not sure I fully understand, but one thing to note is that the log output i'm retrieving doesn't appear to come back as JSON although my AWS CLI config file specifies output=json. The log output before it hits an error prints a bunch of lines, but when it hits a set of lines of which the actual log output contains JSON objects it throws this error.
Results:
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.8.5 (default, Jul 21 2020, 10:48:26)
[Clang 11.0.3 (clang-1103.0.32.62)]
boto3 version: 1.14.20
Platform: macOS-10.15.6-x86_64-i386-64bit
Args: ['/usr/local/bin/awslogs', 'get', '/aws/lambda/mylambda', '--query=message', '--start=Sept 18 22:10:00 UTC 2020', '--end=Sept 18 22:20:00 UTC 2020']
Config: {'aws_access_key_id': 'SENSITIVE', 'aws_secret_access_key': 'SENSITIVE', 'aws_session_token': 'SENSITIVE', 'aws_profile': 'SENSITIVE', 'aws_region': None, 'aws_endpoint_url': None, 'log_group_name': '/aws/lambda/mylambda', 'log_stream_name': 'ALL', 'filter_pattern': None, 'watch': False, 'watch_interval': 1, 'output_group_enabled': True, 'output_stream_enabled': True, 'output_timestamp_enabled': False, 'output_ingestion_time_enabled': False, 'start': 'Sept 18 22:10:00 UTC 2020', 'end': 'Sept 18 22:20:00 UTC 2020', 'color': 'auto', 'query': 'message', 'func': 'list_logs'}
Traceback (most recent call last):
File "/usr/local/Cellar/awslogs/0.14.0/libexec/lib/python3.8/site-packages/awslogs/bin.py", line 179, in main
getattr(logs, options.func)()
File "/usr/local/Cellar/awslogs/0.14.0/libexec/lib/python3.8/site-packages/awslogs/core.py", line 229, in list_logs
consumer()
File "/usr/local/Cellar/awslogs/0.14.0/libexec/lib/python3.8/site-packages/awslogs/core.py", line 212, in consumer
parsed = json.loads(event['message'])
File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/__init__.py", line 357, in loads
return _default_decoder.decode(s)
File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/json/decoder.py", line 353, in raw_decode
obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)