1

I am having a chalice app which exposes some urls backed by api gateway and lambda function. What I want is to log the request id with each and every log msg for debugging purposes. Below is how my code looks like.

@app.route('/instrument', methods=['GET'])
@logging_and_error_handling()
def get_instrument_value():
 // some code
 // logger.log() Here I want to put the request id.

I can see that request id is getting logged in the cloudwatch by default. I want to use the same request id. How do I capture it inside my method ?

enter image description here

Naxi
  • 1,504
  • 5
  • 33
  • 72

1 Answers1

2

You can use aws_request_id in the context object: https://docs.aws.amazon.com/lambda/latest/dg/python-context.html

saart
  • 344
  • 1
  • 5