I'm running an AWS python lambda on a trigger and would like to monitor it using cloudwatch. I'm monitoring cloudwatch "invocations" and "errors" but the are always the same.
What do I need to do in python when the lambda returns so that cloud watch will recognise it as a success/error.
The data that is passed to the lambda will sometimes be poorly formatted and will not be able to be processed - I'd like to return an error at that point that will be recognised by cloudwatch.
I've tried the following but the errors and invocations count is always the same.
return '{"statusCode": 200,"body": "OK"}'
return '{"StatusCode": 200,"body": "OK"}'
return '{"statusCode": 500,"body": "Error"}'
return '{"StatusCode": 500,"body": "Error"}'
What am I missing not understanding?
Updated code with follow but still doesn't work:
if badrecord==False:
return json.dumps({"statusCode": 200,"body": {"message": "OK"}})
else:
return json.dumps({"statusCode": 500,"body": {"message": "Error Bad Record"}})````