Serverless plugin to enable API Gateway logs and extended metrics
$ npm i serverless-apig-logs
Your IAM user should have access to the policy: apigateway:updateStage
.
- Add the plugin to the plugin list :
# serverless.yml
plugins:
- serverless-apig-logs
- Deploy!
$ sls deploy
The plugin provides some configurations. All default values are from CLI options or serverless file.
# serverless.yml
custom:
apigLogs:
region: 'us-east-1' # default to CLI option (--region) or ${self:provider.region}
stage: 'dev' # default to CLI option (--stage) or ${self:provider.stage}
logLevel: 'INFO' # default to CLI option (--apig-log-level) or 'ERROR'
dataTraceEnabled: true # Can be overriden by CLI option (--apig-log-dataTraceEnabled)
metricsEnabled: true # Can be overriden by CLI option (--apig-metricsEnabled)
When parameter dataTraceEnabled
is set to true full request and response bodies can be found in the logs.
Parameter metricsEnabled
enables extended CloudWatch metrics for API (api calls, latency, etc).