1개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
0
If we want to customize the logs from instance for Amazon Linux 2 platform when the application is deployed using elasticbeanstalk, we need to follow these steps:
- Create a custom file in .ebextension/ in the root directory of your application
- Copy the below code and save the file with any name but with .config extension For Eg: custom-logs.config The below code is to include /var/log/messages logs to be streamed to cloudwatch
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/log/messages]
log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/log/messages"]]}`
log_stream_name = {instance_id}
file = /var/log/messages
commands:
"01":
command: systemctl enable awslogsd.service
"02":
command: systemctl restart awslogsd
- Deploy the application.
You should see the logs in cloudwatch for the configured logs.
답변함 9달 전
관련 콘텐츠
- AWS 공식업데이트됨 일 년 전
It seems it is deprecated in AL2023 as awslogs is not available in AL2023. Any updated approach to do this? Thanks.