【问题标题】:AWS API Gateway $input variable in CloudWatchCloudWatch 中的 AWS API Gateway $input 变量
【发布时间】:2018-03-07 02:48:53
【问题描述】:

是否可以记录从 CloudWatch 到 API Gateway 的请求的 $input variable(正文变量)?

自定义访问日志的日志格式似乎不接受 $input.body 或任何其他 $input 函数:

{"requestId": "$context.requestId",  "ip": "$context.identity.sourceIp",  "caller": "$context.identity.caller",  "user": "$context.identity.user",  "requestTime": "$context.requestTime",  "httpMethod": "$context.httpMethod",  "resourcePath": "$context.resourcePath",  "status": "$context.status",  "protocol": "$context.protocol",  "responseLength": "$context.responseLength", "body": "$input.body", params: "$input.params()"}

【问题讨论】:

标签: amazon-web-services aws-api-gateway amazon-cloudwatch


【解决方案1】:

简短回答:否

您可以在访问日志中使用$context 变量,如

中所述

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-logging.html.

不支持包括$input 在内的其他变量。如果要记录请求/响应标头值,可以使用执行记录并启用“记录完整请求/响应数据”。

【讨论】:

    猜你喜欢
    • 2020-05-27
    • 1970-01-01
    • 2017-10-10
    • 2020-10-25
    • 1970-01-01
    • 2021-11-03
    • 2021-03-26
    • 2017-09-19
    • 2021-05-21
    相关资源
    最近更新 更多