Automatically setting CloudWatch log group retention to reduce cost
Amazon CloudWatch collects metrics, logs, and events from your resources by default. These logs could then be used to build dashboards, alarms, and alerts. By default, Amazon CloudWatch Logs stores your log data indefinitely, which can add up the cost, particularly when you use detailed monitoring instead of basic monitoring. Using Lambda to automatically check log groups within the regions of your services and data lake can help you save on storage costs.
Getting ready
Before reducing logging costs, you need to have a strategy. Good logging leads to good monitoring. A sizable number enables humans and machines to analyze information. It would be best to have a logging strategy that can answer questions such as “who did what and when?” without including sensitive information such as passwords or secrets before trying to reduce the number of logs.
How to do it…
- In the Home console...