由于日志轮换,我在Elastic Beanstalk实例中出现内存磁盘问题,因此我尝试通过遵循文档来修改日志轮换的默认配置:
https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.logging.html
添加我的配置并重建环境后,当我通过SSH连接到EB时,可以看到我的配置(在指定的路径中)。但是,看来我的更改没有应用,日志也不会根据我的配置旋转。
##################################################################
## Sets up the elastic beanstalk log publication to include
## the admin logs for cloudwatch logs
##################################################################
Resources:
AWSEBAutoScalingGroup:
Metadata:
"AWS::CloudFormation::Init":
configSets:
"_OnInstanceBoot":
"CmpFn::Insert":
values:
- EBCWLLogPublicationSetup
EBCWLLogPublicationSetup:
files:
"/etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.awslogs.conf":
content: |
/var/log/awslogs.log {
size 2M
rotate 3
missingok
compress
notifempty
copytruncate
dateext
dateformat %s
olddir /var/log/rotated
}
mode: "000644"
我的EB实例包含一个经过码头化的Java应用程序(dropwizard,Java 1.8)。
任何想法?
最后,我可以找到一种可行的方法:
container_commands:
01-custom-rotate:
command: "/bin/sed -i 's/size 10M/size 7M/g' /etc/logrotate.elasticbeanstalk.hourly/logrotate.elasticbeanstalk.awslogs.conf"
基本上,它将替换配置文件中的文本。仍然需要重建EB才能看到更改。