Skip to content

Commit edf4e20

Browse files
author
Phil Varner
authored
API Gateway logging example (#546)
* Add API Gateway logging configuration example * Add API Gateway logging configuration example * fix typo
1 parent 082bd0a commit edf4e20

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased] - TBD
9+
10+
### Added
11+
12+
- Added API Gateway logging config to example serverless.yml config.
13+
814
## [2.2.0] - 2023-07-03
915

1016
### Changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
- [Proxying Stac-server through CloudFront](#proxying-stac-server-through-cloudfront)
3030
- [Locking down transaction endpoints](#locking-down-transaction-endpoints)
3131
- [AWS WAF Rule Conflicts](#aws-waf-rule-conflicts)
32+
- [API Gateway Logging](#api-gateway-logging)
3233
- [Queryables](#queryables)
3334
- [Aggregation](#aggregation)
3435
- [Ingesting Data](#ingesting-data)
@@ -839,6 +840,19 @@ This is also triggered when using pystac_client with no filtering parameters.
839840
The fix is to disable the WAF SQL injection rule, which is unnecessary because
840841
stac-server does not use SQL.
841842

843+
### API Gateway Logging
844+
845+
The example serverless.yml config contains disabled configuration for setting up
846+
API Gateway logging of API requests. More information about these configuration can be
847+
found in the [Serverless Framework API Gateway Documentation](https://www.serverless.com/framework/docs/providers/aws/events/apigateway#logs).
848+
849+
The `executionLogging` setting causes logging of the actual execution of the API Gateway
850+
endpoints and backing Lambda, with `fullExecutionData` causing the entire request and
851+
response to be logged to CloudWatch, which can be expensive.
852+
853+
The `accessLogging` setting logs the values specified in `format` to CloudWatch, which
854+
can be useful for computing metrics on usage for the API.
855+
842856
## Queryables
843857

844858
STAC API supports the Query Extension. Unlike the Filter Extension (which is not supported),

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"typecheck": "tsc",
2424
"audit-prod": "npx better-npm-audit audit --production -x 1091470",
2525
"deploy": "sls deploy",
26+
"destroy": "sls destroy",
2627
"package": "sls package",
2728
"serve": "REQUEST_LOGGING_FORMAT=dev LOG_LEVEL=debug STAC_API_URL=http://localhost:3000 ENABLE_TRANSACTIONS_EXTENSION=true nodemon --esm ./src/lambdas/api/local.ts",
2829
"build-api-docs": "npm run widdershins --search false --language_tabs 'nodejs:NodeJS' 'python:Python' --summary ./packages/api-lib/api-spec.yaml -o ./docs/api.md & npm run shins --inline --logo ./docs/images/logo.png -o ./docs/index.html ./docs/api.md",

serverless.example.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ provider:
88
# uncomment this if using a bucket that already exists for deployment files
99
# deploymentBucket:
1010
# name: my-deployment-bucket
11+
logs:
12+
restApi:
13+
executionLogging: false
14+
fullExecutionData: false
15+
accessLogging: false
16+
format: '{"requestId":"$context.requestId","ip":"$context.identity.sourceIp","caller":"$context.identity.caller","useragent" : "$context.identity.userAgent","requestTime":"$context.requestTime","httpMethod":"$context.httpMethod","resourcePath":"$context.resourcePath","status":"$context.status","protocol":"$context.protocol","responseLength":"$context.responseLength"}'
1117
environment:
1218
STAC_ID: "stac-server"
1319
STAC_TITLE: "STAC API"

0 commit comments

Comments
 (0)