Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS API Gateway: Log Query String in Access Log

I've enabled Access Logging to CloudWatch for my API in AWS API Gateway and that works fine. However, it will only log the path section of the URL and not my query string parameters.

My log format looks like this:

[$context.requestTime] ($context.status) "$context.httpMethod $context.path $context.requestId

Let's say, I call my API like this:

GET http://my.server.com/details?id=123

The corresponding access log line will look like this:

[19/Jun/2018:06:09:27 +0000] (200) "GET /details 5229a43c-7387-11e8-xxxx-xxxxxxxx

I need the id=123 as well, but I can't figure out how to access it. The documentation suggest using $input.params('id'), but that will always return -.

like image 664
Phil Avatar asked Jun 19 '18 06:06

Phil


1 Answers

Only $context variables are supported, not $input, etc. AWS Ref: Have you seen https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html?

like image 177
Andres Luque Avatar answered Sep 27 '22 02:09

Andres Luque