aws/amazon-cloudwatch-agent

Rotate amazon-cloudwatch-agent.log

ShawneeY opened this issue · 2 comments

Is your feature request related to a problem? Please describe.
amazon-cloudwatch-agent.log contains logs created by the cw-log-agent itself. Does amazon-cloudwatch-agent.log rotate ? If not, does the agent remove old log entries from this single log file ?

Describe the solution you'd like
Add a config to rotate amazon-cloudwatch-agent.log so old log_files can be auto-removed via the auto_removal flag

Describe alternatives you've considered
Configure another process to periodically clean-up amazon-cloudwatch-agent.log

Additional context
Not applicable

Hi! We are currently supporting log rotation. You can define it in your configuration under logs->collect list. Here is an example:

{
  "logs": {
    "logs_collected": {
      "files": {
        "collect_list": [
          {
            "file_path": "/var/log/myapp/app.log",
            "log_group_name": "myapp/app.log",
            "retention_in_days": 30
          }
        ]  
      }
    }
  }
}

For more information you can take a look at this documentation: CloudWatch-Agent-Configuration-File-Logssection

Please let me know if you have any other questions!

As mentioned in the documentation for the agent section's logfile,

The CloudWatch agent automatically rotates the log file that it creates. A log file is rotated out when it reaches 100 MB in size. The agent keeps the rotated log files for up to seven days, and it keeps as many as five backup log files that have been rotated out. Backup log files have a timestamp appended to their filename. The timestamp shows the date and time that the file was rotated out: for example, amazon-cloudwatch-agent-2018-06-08T21-01-50.247.log.gz.

Are you seeing different behavior?