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?
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With