12

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?

Szymon Jednac
  • 2,969
  • 1
  • 29
  • 43
Know Nothing
  • 1,121
  • 2
  • 10
  • 21

2 Answers2

12

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
Szymon Jednac
  • 2,969
  • 1
  • 29
  • 43
6

For changing log data retention in CloudWatch you can:

  1. go to CloudWatch console
  2. choose Logs in the navigation pane
  3. find your log group
  4. 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.

Mahdi
  • 3,199
  • 2
  • 25
  • 35
  • Thanks @Mahdi. But we log groups are created by ECS user data. So it would be great if we can setup this retention days in user data instead of going to console after. – Know Nothing Jul 20 '17 at 16:20