将Api Gateway请求/响应正文/标头记录到ElasticSearch

时间:2019-03-15 14:15:05

标签: aws-lambda aws-api-gateway aws-elasticsearch amazon-cloudwatch

默认情况下很容易设置它,但是我不能更改消息的格式。它发送到CloudWatch

Api Gateway充当代理

  

2019-03-15 13:31:22.248(REQ_ID)方法已完成,状态为200

     

2019-03-15 13:31:22.248(REQ_ID)成功完成执行

     

2019-03-15 13:31:22.248(REQ_ID)方法响应标头:   {Cache-Control = max-age = 0,私有,必须重新验证,   Content-Type =应用程序/ json; charset = utf-8,Date = Fri,15 Mar 2019   13:31:22 GMT,ETag = W /“ 607046c7bacdeee5e27e99f48fa2e053”,   服务器= nginx / 1.12.1 + Phusion Passenger 4.0.60,状态= 200,   Vary =接受编码,来源,X-Content-Type-Options = nosniff,   X-Frame-Options = SAMEORIGIN,X-Powered-By = Phusion Passenger 4.0.60,   X-Request-Id = 88c8f3c2-0a25-4445-9010-30d4753b855a,X运行时= 0.030736,   X-XSS-Protection = 1; mode = block,Connection = keep-alive}

     

2019-03-15 13:31:22.248(REQ_ID)方法响应正文   转换:{“成功”:1,“消息”:“令牌无效”}

     

2019-03-15 13:31:22.248(REQ_ID)端点响应标头:   {Cache-Control = max-age = 0,私有,必须重新验证,   Content-Type =应用程序/ json; charset = utf-8,Date = Fri,15 Mar 2019   13:31:22 GMT,ETag = W /“ 607046c7bacdeee5e27e99f48fa2e053”,   服务器= nginx / 1.12.1 + Phusion Passenger 4.0.60,状态= 200,   Vary =接受编码,来源,X-Content-Type-Options = nosniff,   X-Frame-Options = SAMEORIGIN,X-Powered-By = Phusion Passenger 4.0.60,   X-Request-Id = 88c8f3c2-0a25-4445-9010-30d4753b855a,X运行时= 0.030736,   X-XSS-Protection = 1;模式=区块,传输编码=区块,   Connection =保持活动}

     

2019-03-15 13:31:22.248(REQ_ID)端点响应正文之前   转换:{“成功”:1,“消息”:“令牌无效”}

     

2019-03-15 13:31:22.248(REQ_ID)收到响应。积分   延迟:43毫秒

     

2019-03-15 13:31:22.205(REQ_ID)正在向发送请求   https://proxy.domain.com/api/endpoint

     

2019-03-15 13:31:22.205(REQ_ID)端点请求正文在   转换:{“ message”:“ hello world”}

     

2019-03-15 13:31:22.205(REQ_ID)端点请求标头:   {x-amzn-apigateway-api-id = API,User-Agent = curl / 7.54.0,   X-Forwarded-Proto = https,X-Forwarded-For = 195.24.159.254,   content-type =应用程序/ json,X-Forwarded-Port = 443,   X-Amzn-Trace-Id = Root = 1-5c8ba92a-7fb7fa94b9991bb8f1561d55,accept = / }

     

2019-03-15 13:31:22.205(REQ_ID)端点请求URI:   https://proxy.domain.com/api/endpoint

     

2019-03-15 13:31:22.119(REQ_ID)方法请求正文之前   转换:{“ message”:“ hello world”}

     

2019-03-15 13:31:22.119(9f76246a-4726-11e9-a18d-25bda2ff1f7b)方法   请求标头:{User-Agent = curl / 7.54.0,X-Forwarded-Proto = https,   X-Forwarded-For = 195.24.159.254,content-type = application / json,   主机= api.execute-api.eu-west-1.amazonaws.com,X-Forwarded-Port = 443,   X-Amzn-Trace-Id = Root = 1-5c8ba92a-7fb7fa94b9991bb8f1561d55,accept = / }

     

2019-03-15 13:31:22.119(REQ_ID)方法请求查询字符串:{}

     

2019-03-15 13:31:22.119(REQ_ID)方法请求路径:   {proxy = api / endpoint}

我只需要向JSON发送这4列:ES的request_header,request_body,response_header,response_body。现在,它为每个请求发送上面的所有日志。

0 个答案:

没有答案