Elastic Beanstalk:在Amazon Linux 2平台上自定义日志任务 [英] Elastic Beanstalk: log task customization on Amazon Linux 2 platforms

查看:42
本文介绍了Elastic Beanstalk:在Amazon Linux 2平台上自定义日志任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何做日志任务自定义.具体来说,我正在比较:

I'm wondering how to do log task customization in the new Elastic Beanstalk platform (the one based on Amazon Linux 2). Specifically, I'm comparing:

  • :在64位Amazon Linux/2.14.3上运行的单容器Docker
  • :在64位Amazon Linux 2/3.0.0上运行的单容器Docker
  • Old: Single-container Docker running on 64bit Amazon Linux/2.14.3
  • New: Single-container Docker running on 64bit Amazon Linux 2/3.0.0

(我的问题实际上与Docker无关,我推测任何新的Elastic Beanstalk平台都存在该问题.)

(My question actually has nothing to do with Docker as such, I'm speculating the problem exist for any of the new Elastic Beanstalk platforms).

以前,我可以遵循亚马逊的配方,这意味着将文件放入/opt/elasticbeanstalk/tasks/bundlelogs.d/中,然后将其执行.这不再是事实.

Previously I could follow Amazon's recipe, meaning put a file into /opt/elasticbeanstalk/tasks/bundlelogs.d/ and it would then be acted upon. This is no longer true.

这个改变了吗?我找不到记录.在更新的Elastic Beanstalk平台上成功完成日志任务自定义的人吗?如果可以,怎么办?

Has this changed? I can't find it documented. Anyone been successful in doing log task customization on the newer Elastic Beanstalk platform? If so, how?

我创建了一个最小的工作示例,并部署在两个平台上.

I've created a minimal working example and deployed on both platforms.

Dockerfile :

FROM ubuntu
COPY daemon-run.sh /daemon-run.sh
RUN chmod +x /daemon-run.sh
EXPOSE 80
ENTRYPOINT ["/daemon-run.sh"]

Dockerrun.aws.json :

{
  "AWSEBDockerrunVersion": "1",
  "Logging": "/var/mydaemon"
}

daemon-run.sh :

#!/bin/bash
echo "Starting daemon" # output to stdout
mkdir -p /var/mydaemon/deeperlogs
while true; do
   echo "$(date '+%Y-%m-%dT%H:%M:%S%:z')  Hello World" >> /var/mydaemon/deeperlogs/app_$$.log
   sleep 5
done

.ebextensions/mydaemon-logfiles.config :

files: 
  "/opt/elasticbeanstalk/tasks/bundlelogs.d/mydaemon-logs.conf" :
    mode: "000755"
    owner: root
    group: root
    content: |
       /var/log/eb-docker/containers/eb-current-app/deeperlogs/*.log

如果我在旧平台上执行完整日志"操作,我将获得包含我的 deeperlogs 的ZIP在 var/log/eb-docker/containers/eb-current-app 中.在新平台上,我不会.

If I do "Full Logs" action on the old platform I would get a ZIP with my deeperlogs included inside var/log/eb-docker/containers/eb-current-app. On the new platform I don't.

如果您查看磁盘,您会发现新的Elastic Beanstalk根本没有/opt/elasticbeanstalk/tasks 文件夹,这与旧的文件夹不同.嗯.

If you look on the disk you'll see that the new Elastic Beanstalk doesn't have a /opt/elasticbeanstalk/tasks folder at all, unlike the old one. Hmm.

推荐答案

Amazon已在Elastic Beanstalk AL2平台的版本中解决了此问题

Amazon has fixed this problem in version of the Elastic Beanstalk AL2 platforms released on 04-AUG-2020.

此问题已得到修复,因此在基于AL2的平台上进行日志任务自定义现在可以按一如既往的方式运行(即在预生成版本AL2018平台上),因此您可以按照

It has been fixed so that log task customization on AL2-based platforms now works the way it has always worked (i.e. on the prevision generation AL2018 platforms) and you can therefore follow the official documentation in order to make this happen.

使用平台在64位Amazon Linux 2/3.1.0&上运行的Docker"成功测试..如果(仍然)使用在64位Amazon Linux 2/3.0.x上运行的Docker" ,则必须使用未记录的解决方法

Succesfully tested with platform "Docker running on 64bit Amazon Linux 2/3.1.0". If you (still) use "Docker running on 64bit Amazon Linux 2/3.0.x" then you must use the undocumented workaround described in Marcin's answer but you are probably better off by upgrading your platform version.

这篇关于Elastic Beanstalk:在Amazon Linux 2平台上自定义日志任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆