'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?
Solution 1:[1]
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
Solution 2:[2]
For changing log data retention in CloudWatch you can:
- go to CloudWatch console
- choose Logs in the navigation pane
- find your log group
- change the value of the Expire Event After column
Here you can find a list of other parameters you can set in the config file.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Szymon Jednac |
| Solution 2 | Mahdi |
