1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
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.
respondido há 9 meses
Conteúdo relevante
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 2 anos
- Como soluciono erros relacionados à transmissão do CloudWatch para um ambiente do Elastic Beanstalk?AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há 7 meses
It seems it is deprecated in AL2023 as awslogs is not available in AL2023. Any updated approach to do this? Thanks.