2

I am trying to log Lambda function failures in such a way that event and context information is saved so that the event information can, if deemed necessary, later be manually republished to the function's trigger. I do not want to handle this logic in the functions themselves.

What I've tried so far:

  • CloudWatch alarms on the error metric. They tell me only that a function has failed.
  • Looking in the CloudWatch logs. I only see the coded failure messages emitted from each function.

1 Answer 1

2

There is no such setting, if that's what you're looking for.

If you'd like these properties to be logged, you have to print them - only that way they are visible in CloudWatch and whatever service that your logs are piped to (logs can be piped to Elasticsearch for example, from CloudWatch).

However, this can be easily done adding these two lines of code:

exports.handler = (event, context, callback) => {
  console.log(JSON.stringify(event));
  console.log(JSON.stringify(context));

  // your code
};

As a rule of thumb, logs are the only way for describing what your lambda went through at each invocation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.