- Le plus récent
- Le plus de votes
- La plupart des commentaires
It doesn't look like it is possible to log header in the API Gateway access log. From the documentation, only the following variables can be logged from API Gateway access logs to Cloudwatch - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-logging-variables.html
Having said that, it is possible to log the headers in the backend integration lambda.
I used this tutorial https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-dynamo-db.html and just modified the lambda function code to log the event object
const AWS = require("aws-sdk");
const dynamo = new AWS.DynamoDB.DocumentClient();
exports.handler = async (event, context) => { let body; let statusCode = 200; const headers = { "Content-Type": "application/json" }; console.log("#####################") console.log(event) console.log("#####################") try { .....rest of the code
When I called the API from the API Gateway, I do see the headers getting logged in the Cloudwatch logs of the lambda function.
Contenus pertinents
- demandé il y a un an
- demandé il y a 6 mois
- demandé il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 4 ans
- AWS OFFICIELA mis à jour il y a 2 ans
Thank you! I'll go ahead and continue to log the headers at the Lambda level. That should be enough since I am able to get the original user ip from the headers that way.