Skip to content

Instantly share code, notes, and snippets.

@alexcasalboni alexcasalboni/
Last active Jun 17, 2019

What would you like to do?
AWS CloudWatch Logs - Lambda handler
import time
import boto3
from decode import decode # see
cloudwatch_logs = boto3.client('logs')
def handler(event, context):
obj = decode(event['awslogs']['data'])
# wait for other logs to be collected in the stream
full_logs = fetch_log_stream(obj)
# TODO also fetch x-ray traces based on request_id
# TODO create new issue on GitHub with logs and traces
return "OK"
def fetch_log_stream(obj):
return cloudwatch_logs.get_log_events(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.