1

Is there any possible way to log the name of the Lambda in CloudWatch ?

Ex:

START RequestId: 4b453a3-f239-461f-94ab-ebesdfsdb04de Version: $LATEST

The "RequestId" is already getting logged. Any property I can use to log the name of the lambda as well ?

I don't want an explicit console.log statement but a property/parameter which directly gives out my lambda's name along with START , END and INFO fields.

3 Answers 3

1

You should be using context property (function_name).

def lambda_handler(event, context):
    print("lambda function: {}".format(context.function_name)) 

Please refer below link for more details.

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

Comments

0

You coud use environment variable AWS_LAMBDA_FUNCTION_NAME (see full list). If your Lambda are written on Python it could looks like this:

import os

def lambda_handler(event, context):
    print("Running function '%s'" % os.environ.get('AWS_LAMBDA_FUNCTION_NAME', None))

Comments

0

could do this in nodejs

console.log(process.env.AWS_LAMBDA_FUNCTION_NAME)

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.