1

I have a REST API exposed in API Gateway and those requests have path params and query params. I want to store some data from the request in CloudWatch.

In the settings I have checked the Log full requests/responses data option.

enter image description here

In the Custom Access Logging I have checked Enable Access Logging and this log format:

{"requestId":"$context.requestId", "carId":"method.request.querystring.carId","color":"$input.params('color')"}

But in CloudWatch the result is:

{"requestId":"XXXXXX", "carId":"-","color":"-"}

Following the AWS documentation: https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference%3Fcmpid=docs_apigateway_console

The request is: https://test.domain.demo/v1/cars/123456/data?color=red

Why I am getting a - instead of the correct value?

user1911
  • 680
  • 1
  • 14
  • 36
  • 1
    Only $context variables are supported (not $input, and so on) in Access logging. reference - https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html – Manjeet Rulhania Nov 02 '20 at 18:43

0 Answers0