我有一个使用Docker容器部署的Elastic Beanstalk应用程序。应用程序本身就是Java应用程序。
我的目标是将日志发送到Cloudwatch。特别是,我希望将stdouterr.log文件放到Cloudwatch中。该文件可以在/var/log/eb-docker/containers/eb-current-app/*
下找到
我遵循了亚马逊网络服务的官方文档here。根据示例配置文件,我设法将nginx Webrequest发送到Cloudwatch。
对于EB docker stdouterr日志,我将cwl- log -setup.config文件修改为:
Mappings:
CWLogs:
ApplicationLogGroup:
LogFile: "/var/log/eb-docker/containers/eb-current-app/*"
TimestampFormat: "%d/%b/%Y:%H:%M:%S %z"
Outputs:
ApplicationLogGroup:
Description: "The name of the Cloudwatch Logs Log Group created for this environments web server access logs. You can specify this by setting the value for the environment variable: WebRequestCWLogGroup. Please note: if you update this value, then you will need to go and clear out the old cloudwatch logs group and delete it through Cloudwatch Logs."
Value: { "Ref" : "AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0WebRequestLogGroup"}
Resources :
AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0WebRequestLogGroup: ## Must have prefix: AWSEBCloudWatchLogs8832c8d3f1a54c238a40e36f31ef55a0
Type: "AWS::Logs::LogGroup"
DependsOn: AWSEBBeanstalkMetadata
DeletionPolicy: Retain ## this is required
Properties:
LogGroupName:
"Fn::GetOptionSetting":
Namespace: "aws:elasticbeanstalk:application:environment"
OptionName: ApplicationLogGroup
DefaultValue: {"Fn::Join":["-", [{ "Ref":"AWSEBEnvironmentName" }, "webrequests"]]}
RetentionInDays: 14
创建了cloudwatch日志组,但没有日志到达。我在配置文件中遗漏了哪些步骤或哪里出错了?
发布于 2018-06-06 06:31:11
我为每个ElasticBeanstalk应用程序创建Dockerrun文件。https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_docker_image.html
您可以在其中指定日志记录配置:
"logConfiguration": {
"logDriver": "awslogs",
"options": {
"awslogs-group": "${you-log-group-name}",
"awslogs-region": "${region}",
"awslogs-stream-prefix": "${serviceName}"
}
}
这将设置Docker的日志驱动程序配置更多详细信息:https://docs.docker.com/config/containers/logging/configure/
发布于 2021-09-07 17:58:37
现在,在Amazon Linux 2的docker平台上,使用docker-compose.yaml就可以做到这一点:
version: '3.8'
services:
your-service:
logging:
driver: awslogs
options:
awslogs-group: "${your-log-group-name}"
awslogs-region: "us-west-2"
查看此处了解更多选项:https://docs.docker.com/config/containers/logging/awslogs/
https://stackoverflow.com/questions/36451420
复制相似问题