Some configuration for AWS API Gateway HTTP API with logging based on https://www.alexdebrie.com/posts/api-gateway-access-logs/
BackendAPI:
Type: AWS::Serverless::HttpApi
Properties:
DefaultRouteSettings:
ThrottlingBurstLimit: 10
ThrottlingRateLimit: 10
DetailedMetricsEnabled: true
AccessLogSettings:
DestinationArn: !GetAtt BackendAccessLogGroup.Arn
Format: '{"requestTime":"$context.requestTime","requestId":"$context.requestId","httpMethod":"$context.httpMethod","path":"$context.path","resourcePath":"$context.resourcePath","status":$context.status,"responseLatency":$context.responseLatency,"ip":"$context.identity.sourceIp","userAgent":"$context.identity.userAgent","integrationRequestId":"$context.integration.requestId","functionResponseStatus":"$context.integration.status","integrationLatency":"$context.integration.latency","integrationServiceStatus":"$context.integration.integrationStatus"}'
The first entry is a lambda log line and the second is API Gateway access log.
2021/11/23/[$LATEST]56604917d020438e8fb951c0cdafd3b6 2021-11-23T05:13:56.395000 {
"level": "info",
"version": "25f604d",
"aws_request_id": "24571860-d277-4f87-abc12-5b404e4101b2",
"amzn_trace_id": "Root=1-619c7894-63e493da38e160a91da230ab;Parent=5bdba4dc67b01709;Sampled=0",
"dur": "197.583976ms",
"ip": "x.x.x.x",
"length": 1195,
"method": "GET",
"path": "/latency_data",
"status": 200,
"caller": "github.com/wolfeidau/[email protected]/zlog_requests.go:49",
"message": "processed request"
}
2021/11/23/[$LATEST]56604917d020438e8fb951c0cdafd3b6 2021-11-23T05:13:56.396000 END RequestId: 24571860-d277-4f87-abc12-5b404e4101b2
2021/11/23/[$LATEST]56604917d020438e8fb951c0cdafd3b6 2021-11-23T05:13:56.396000 REPORT RequestId: 24571860-d277-4f87-abc12-5b404e4101b2 Duration: 199.05 ms Billed Duration: 200 ms Memory Size: 256 MB Max Memory Used: 55 MB
abc123abc123_.default-2021-11-23-05-13 2021-11-23T05:13:56.174000 {
"requestTime": "23/Nov/2021:05:13:56 +0000",
"requestId": "JPfHLjaFvHcEPcQ=",
"httpMethod": "GET",
"path": "/latency_data",
"resourcePath": "-",
"status": 200,
"responseLatency": 220,
"ip": "x.x.x.x",
"userAgent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0",
"integrationRequestId": "24571860-d277-4f87-abc12-5b404e4101b2",
"functionResponseStatus": "200",
"integrationLatency": "215",
"integrationServiceStatus": "200"
}
How is BackendAccessLogGroup setup?