Ivo Janssen
Ivo Janssen

Reputation: 476

How to change settings for logrotate in AWS Elastic Beanstalk docker instances

I realized that the default logrotation for AWS EB's docker is 5 files of 10M each. That's not enough for me.

I found the config at /etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.applogs.conf and it reads as follows:

  $ cat /etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.applogs.conf
  /var/log/eb-docker/containers/eb-current-app/* {
  size 10M
  rotate 5
  missingok
  compress
  notifempty
  copytruncate
  dateext
  dateformat %s
  olddir /var/log/eb-docker/containers/eb-current-app/rotated
  }

I'd like to change that to a larger size, let's say 5 files of a gig each. How to accomplish this?

I'm familiar with the .ebextensions framework, and I think the answer lies by writing an ebextension. The preferred answer changes just the "size" parameter in the existing configuration, without writing in a whole new file, because I'd like to take advantage in any future changes that AWS makes in their docker offering.

Upvotes: 4

Views: 5872

Answers (1)

bhangm
bhangm

Reputation: 607

If I understand correctly, your aim is to have more history available than the default offers. One way to accomplish this is to enable Log publication to S3. This option is available under Software configuration on the Configuration page for each environment.

Publish Logs setting

This setting will ensure that logs locally rotated out are uploaded to a location in S3. This location is typically under the default bucket that AWS Elastic Beanstalk creates to store artifacts and logs. The bucket name is of the format:

    s3://elasticbeanstalk-<region>-<account id>
Ex: s3://elasticbeanstalk-us-east-1-0123456789012

and the path to the logs is:

/resources/environments/logs/publish/<environment id>/<instance id>

Full example:

s3://elasticbeanstalk-us-east-1-0123456789012/resources/environments/logs/publish/e-mpcwnwheky/i-0a1fd158

Things to note

The instance profile that is selected will need the necessary permissions to upload the log files to the S3 bucket at the location specified above.

Logs that are uploaded to S3 are retained there until explicit action is taken such as to delete them or move them to glacier.

Source: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html#health-logs-s3location

Upvotes: 4

Related Questions