How are CloudWatch Laravel logs deployed to AWS Elastic Beanstalk?
1 answer
You need to configure the CloudWatch agent as described here :
- Grant IAM permissions for the CloudWatch Log Agent;
- Deploy the application using the .ebextensions / logs.config file .
I am guessing the 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
Refer to /var/log/awslogs.log in ec2 instance for troubleshooting.
+5
source to share