Skip to content

Commit

Permalink
fix handler key error
Browse files Browse the repository at this point in the history
  • Loading branch information
thecraftman committed Aug 1, 2023
1 parent 6401bc6 commit baf99ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ def push_events_to_axiom(events: list):


def data_from_event(event: dict) -> dict:

if "awslogs" not in event or "data" not in event["awslogs"]:
logger.warning(f"Unexpected event format: {json.dumps(event)}")
return {}

body = base64.b64decode(event["awslogs"]["data"])
data = gzip.decompress(body)
return json.loads(data)
Expand Down Expand Up @@ -137,6 +142,8 @@ def lambda_handler(event: dict, context=None):
raise Exception("AXIOM_DATASET is not set")

data = data_from_event(event)
if not data:
return

aws_fields = {
"owner": data.get("owner"),
Expand Down

0 comments on commit baf99ae

Please sign in to comment.