2
votes

I have been working on a REST API which uses AWS API Gateway and lambda function. Both Api gateway and lambda services are logging to CloudWatch service. I need to log lambda request id into AWS CloudWatch API gateway log group. (API-Gateway-Execution-Logs_{api_id}/{staging}).

I manage to get the lambda request id in text format but I want to log it in JSON format. In API gateway logs it is labeled as "AWS Integration Endpoint RequestId". I have tried to find this property from the following link: List of Log Variables

Currently, "$context.requestId" is added into my CloudWatch logs. This is the request id for API Gateway. I need lambda request id in API Gateway logs. I have tried to log "$context.authorizer.principalId" but it is empty.

How can I get lambda request id from context object of API gateway request?

1

1 Answers

0
votes

From the APIG reference, it seems that you can use the $context.awsEndpointRequestId placeholder