Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AWS CLOUDWATCH LOGS_$context.requestOverride.header.*
#6
(26-08-2022, 01:51 PM)Jyotheesh_K Wrote: I have created a Rest APIGW and created a log group in Cloud Watch and configured a logs in log format. 

Now, making a get call to APIGW. In headers I am sending TransactionID. How to capture this header in Logs. Please find below attached screenshot.

I am able to capture rest of the logs. Is there any context variable to extract headers in log format?


From what I know, the standard API logs wont capture custom header variables. As shown on this link, only a set of predefined headers or other context variables are available for logging in the standard API logs. To actually get the header, you have a couple of options.

1. If you have already enabled custom logging to cloudwatch, make sure the "Log the full request/response data" is checked in the API Stage Log/Trace. Warning: This will generate over 20-40 lines of logs for each request, so consider your logging cost when enabling this.

2. Use lambda proxy-intergration to pass this header variable to lambda to then log it into cloudwatch, which can be achieved by using custom request body mapping templates in API GW.

I would also recommend reading this blog post for a more detailed explanation.
Reply


Messages In This Thread
RE: AWS CLOUDWATCH LOGS_$context.requestOverride.header.* - by fzs - 27-08-2022, 10:49 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)