Prompt
api gateway audit logs tracing
Latest observation
Oct 22, 2026
OpenAI APIWeb search: off
API Gateway audit logs and tracing usually refer to two different observability needs:
1) Audit logs
Used for security, compliance, and forensic review.
Typical things captured:
- Who called the API
- When the request happened
- What resource/endpoint was accessed
- Result status: success/failure
- Auth details: API key, IAM principal, JWT subject, etc.
- Source IP / user agent
- Request ID / correlation ID
Audit logs are usually kept:
- Immutable or tamper-evident
- With controlled access
- For a defined retention period
2) Tracing
Used for debugging and performance analysis across services.
Typical things captured:
- Request path through API Gateway and downstream services
- Latency per hop
- Error propagation
- Distributed trace IDs / span IDs
Tracing usually integrates with:
- OpenTelemetry
- AWS X-Ray
- Jaeger / Zipkin
- Datadog / New Relic / etc.
In API Gateway specifically
If you mean AWS API Gateway, common options are:
Logging
- Execution logs: detailed request/response processing logs
- Access logs: structured logs per request, often sent to CloudWatch Logs
Tracing
- X-Ray tracing can be enabled for API Gateway
- Propagates trace context to backend services if supported
Best practice setup
A solid setup usually includes:
- Access logs with a JSON format
- Execution logs only at needed verbosity
- Correlation ID passed from gateway to backend
- Distributed tracing enabled
- Security monitoring on logs for suspicious behavior
Example access log fields
{
"requestId": "$context.requestId",
"ip": "$context.identity.sourceIp",
"userAgent": "$context.identity.userAgent",
"requestTime": "$context.requestTime",
"httpMethod": "$context.httpMethod",
"path": "$context.resourcePath",
"status": "$context.status",
"responseLength": "$context.responseLength",
"latency": "$context.responseLatency"
}
If you want, I can give you:
- AWS API Gateway audit logging setup
- OpenAPI / Terraform / CloudFormation examples
- How to do tracing with OpenTelemetry/X-Ray
- A checklist for compliance-ready audit logs