- Newest
- Most votes
- Most comments
To control costs related to execution logs in your REST API Gateway, you should understand that when execution logs are activated, API Gateway logs information to CloudWatch. Here are some strategies to manage these costs:
-
Be selective with logging levels: Instead of using "Full request and response logs" (which is set by enabling
dataTraceEnabled), consider using less verbose logging levels. Full request and response logging is not recommended for production APIs anyway due to security concerns. -
Use access logging instead of execution logging: Access logging is generally more cost-effective and provides sufficient information for most use cases. You can customize the log format to include only the information you need.
-
Implement filtering: You can set up CloudWatch Logs filtering to focus only on specific resources or paths that you need to monitor. For example, you can create metric filters that match specific resource paths you want to track.
-
Use CloudWatch Logs Insights: This allows you to query and analyze your logs efficiently without having to process all log data.
-
Monitor and adjust: Regularly review your logging usage and adjust settings as needed. You might find that you don't need certain logs or can reduce the verbosity.
Remember that API Gateway's REST API pricing includes costs for API calls, caching (if enabled), and associated services like CloudWatch for logging. By optimizing your logging strategy, you can significantly reduce your overall costs while still maintaining visibility into your API's performance and usage.
Sources
Custom access logging - cherry-pick resources | AWS re:Post
Secure logging in API Gateway for AWS service APIs - Amazon Marketing Cloud Uploader from AWS
Cost optimization - Best Practices for Designing Amazon API Gateway Private APIs and Private Integration
To reduce execution log costs in your REST API Gateway:
-
Disable full request/response logging (dataTraceEnabled) to avoid verbose logs.
-
Set logging level to ERROR to log only failures.
-
Use access logs instead of execution logs for lighter, customizable logging.
-
Apply CloudWatch log filters to capture only important data.
-
Shorten log retention periods to save storage costs.
-
Use CloudWatch Logs Insights for efficient log analysis without storing excessive data.
These steps help lower your CloudWatch logging costs while maintaining necessary visibility.
Reference:
answered a year ago
Relevant content
asked a year ago
asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
