gpt4 book ai didi

amazon-web-services - 如何在 AWS Elastic Beanstalk 中部署 CloudWatch Laravel 日志?

转载 作者:行者123 更新时间:2023-12-04 23:15:22 24 4
gpt4 key购买 nike

我在 AWS Elastic Beanstalk 中部署了一个 PHP Laravel Worker,并希望流式传输 /var/app/current/storage/logs/*.log云观察 .然而,我遇到的解决方案要么是针对 锻造 部署或 Vanilla EC2 实例。

将不胜感激在这件事上的任何帮助。

最佳答案

您需要按照 here 的说明配置 CloudWatch 代理:

  • 为 CloudWatch Logs 代理授予 IAM 权限;
  • 部署与 一起压缩的应用程序.ebextensions/logs.config 文件。

  • 我假设 日志.config 应该看起来像这样
    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

    请参阅您的 ec2 实例中的/var/log/awslogs.log 以进行故障排除。

    关于amazon-web-services - 如何在 AWS Elastic Beanstalk 中部署 CloudWatch Laravel 日志?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43425401/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com