I have a PHP Laravel Worker deployed in AWS Elastic Beanstalk & wanted to stream the /var/app/current/storage/logs/*.log
to CloudWatch. However the solutions I came across are either for Forge deployments or vanilla EC2 instances.
Would appreciate any help in this matter.
You need to configure CloudWatch agent as described here:
I assume that logs.config should look like this
option_settings:
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: StreamLogs
value: true
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: DeleteOnTerminate
value: false
- namespace: aws:elasticbeanstalk:cloudwatch:logs
option_name: RetentionInDays
value: 7
packages:
yum:
awslogs: []
files:
"/etc/awslogs/awscli.conf" :
mode: "000600"
owner: root
group: root
content: |
[plugins]
cwlogs = cwlogs
[default]
region = `{"Ref":"AWS::Region"}`
"/etc/awslogs/awslogs.conf" :
mode: "000600"
owner: root
group: root
content: |
[general]
state_file = /var/lib/awslogs/agent-state
"/etc/awslogs/config/logs.conf" :
mode: "000600"
owner: root
group: root
content: |
[/var/app/current/storage/logs]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/app/current/storage/logs"]]}`
log_stream_name = {instance_id}
file = /var/app/current/storage/logs/*.log
commands:
"01":
command: chkconfig awslogs on
"02":
command: service awslogs restart
Please refer to /var/log/awslogs.log at your ec2 instance for troubleshooting.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With