1

I would like to be able to see in Cloudwatch metrics (and Lambda metrics) errors for handle exception.

For the moment I see the errors only in Cloudwatch log group for handled errors.

Here is the code I use in my Lambda

def lambda_handler(event, context):
    try:
       raise Exception("My exeception")
    except Exception as e:
       logger.exception(str(e))
       continue

And my logger is defined like this

import logging

logger =  logging.getLogger()
logger.setLevel(logging.INFO)

With this configuration I can just see errors in my logs group, but not in the lamda/cloudwatch metrics

enter image description here

1 Answer 1

1

According to your given code snippet, the lambda execution was completed successfully. To track the failure and success you've to just raise the exception in case of failure and handle it in case of success.

def lambda_handler(event, context):
    # try:
    raise Exception("My exception")
    # except Exception as e:
    # logger.exception(str(e))
    # continue
The logger will show all the logged error/success messages in the stream.

So, if you'll handle the error, then it won't be a failure execution hence no failure on the graph.

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

1 Comment

I would like to be able to see errors even for handled exceptions. What I am looking for, is to manually (with boto3) be able to trigger an error to see it in cloudwatch lambda metrics. Something similar to this, but instead of sending an email, trigger an error to be visible in the cloudwatch lambda metrics.

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.