Cloudwatch Retention
Our lambdas dump logs to AWS CloudWatch. By default, these logs exist indefinitely. However, there are ways to specify a duration for log retention.
aws-cli
In addition to getting your aws-cli set-up, there are two values you'll need to acquire.
log-group-name
: the name of the log group who's retention policy (retention time) you'd like to change. We'll use/aws/lambda/KinesisInboundLogger
in our examples.retention-in-days
: the number of days you'd like to retain the logs in the specified log group for. There is a list of possible values available in the aws logs documentation.
For example, if we wanted to set log retention to 30 days on our KinesisInboundLogger
lambda, we would write:
aws logs put-retention-policy --log-group-name "/aws/lambda/KinesisInboundLogger" --retention-in-days 30
Note: The aws-cli log command that we're using is explained in detail here.
AWS Management Console
Changing the log retention policy in the AWS Management Console is a fairly simple process:
- Navigate to the CloudWatch service in the AWS Management Console.
- Click on the
Logs
entry on the sidebar. - Find the Log Group who's retention policy you're interested in changing.
- Click on the value in the
Expire Events After
column. - Enter/Select the number of days you'd like to retain logs in that log group for.