Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we set cloudwatch log retention days in /etc/awslogs/awslogs.conf

As we know we can put something like this in awslogs.conf file:

[/var/log/mylog]
file = /var/log/mylog.log
log_group_name = mylog
log_stream_name = mystream
datetime_format = %Y-%m-%dT%H:%M:%S.%f

What other parameters can we set in this file? I am looking to set the log retention days - is it possible?

like image 395
Know Nothing Avatar asked Jul 18 '17 17:07

Know Nothing


People also ask

How do you change the retention period in CloudWatch logs?

You can change the log data retention setting for CloudWatch logs. By default, logs are kept indefinitely and never expire. You can adjust the retention policy for each log group, keeping the indefinite retention, or choosing a retention period between 10 years and one day.

How long are CloudWatch logs retained?

You can store your log data in CloudWatch Logs for as long as you want. By default, CloudWatch Logs will store your log data indefinitely. You can change the retention for each Log Group at any time.

Which of the following 3 retention schedules does CloudWatch metrics support?

CloudWatch Metrics now supports the following three retention schedules: 1 minute datapoints are available for 15 days. 5 minute datapoints are available for 63 days. 1 hour datapoints are available for 455 days.

Can CloudWatch logs be modified?

Cloud-watch Log streams helps to listen the event automatically without any triggers. Using this Cloudwatch Log streams we can able to edit the cloud-watch logs.


1 Answers

The awslogs.conf file contains settings for the agent process, which is responsible for putting your log files into CloudWatch Logs. Managing the underlying log groups is out of the scope of it's responsibilities.

Assuming that the log group is created in the user-data script (comments), you could add an additional command for setting the retention period there:

aws logs put-retention-policy --log-group-name mylog --retention-in-days 7
like image 152
Szymon Jednac Avatar answered Sep 24 '22 01:09

Szymon Jednac