Skip to content

Commit

Permalink
Merge 1809d51 into 0886184
Browse files Browse the repository at this point in the history
  • Loading branch information
havocbane committed Aug 28, 2020
2 parents 0886184 + 1809d51 commit d727eef
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ dist
htmlcov/
__pychache__
.vscode
venv/
.idea/
*.iml
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.15.0
======
- Enhanced --query argument to match against message payloads prepended with non-JSON data.

0.14.0
======
- New --aws-endpoint-url option to configure awslogs to use services such localstack, fakes3, etc...
Expand Down
18 changes: 14 additions & 4 deletions awslogs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,22 @@ def consumer():
)
)

# Handle JSON payloads that might be prepended with logging info (level, timestamp, etc.)
message = event['message']
try:
message = message[message.index('{'):]
except ValueError: # Probably not JSON
pass

if self.query is not None and message[0] == '{':
parsed = json.loads(event['message'])
message = self.query_expression.search(parsed)
if not isinstance(message, str):
message = json.dumps(message)
try:
parsed = json.loads(message)
except json.decoder.JSONDecodeError:
pass
else:
message = self.query_expression.search(parsed)
if not isinstance(message, str):
message = json.dumps(message)
output.append(message.rstrip())

print(' '.join(output))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='awslogs',
version='0.14.0',
version='0.15.0',
url='https://github.com/jorgebastida/awslogs',
license='BSD',
author='Jorge Bastida',
Expand Down

0 comments on commit d727eef

Please sign in to comment.