AWS Elastic Beanstalk: Add custom logs to CloudWatch?

后端 未结 4 470
心在旅途
心在旅途 2020-12-23 22:17

How to add custom logs to CloudWatch? Defaults logs are sent but how to add a custom one?

I already added a file like this: (in .ebextensions)

files         


        
4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-23 22:56

    Both bundlelogs.d and taillogs.d are logs retrieved from management console. What you want to do is extend default logs (e.g. eb-activity.log) to CloudWatch Logs. In order to extend the log stream, you need to add another configuration under /etc/awslogs/config/. The configuration should follow the Agent Configuration file Format.

    I've successfully extended my logs for my custom ubuntu/nginx/php platform. Here is my extension file FYI. Here is an official sample FYI.

    In your case, it could be like

    files:
      "/etc/awslogs/config/my_app_log.conf" :
        mode: "000600"
        owner: root
        group: root
        content: |
          [/var/app/current/logs/xxx.log]
          log_group_name = `{"Fn::Join":["/", ["/aws/elasticbeanstalk", { "Ref":"AWSEBEnvironmentName" }, "var/app/current/logs/xxx.log"]]}`
          log_stream_name = {instance_id}
          file = /var/app/current/logs/xxx.log*
    

提交回复
热议问题