Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

505
Views
Elastic Beanstalk: log task customization on Amazon Linux 2 platforms

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:

  • 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

(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).

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.

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?

Minimal working example

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

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.

Investigation

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.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

On Amazon Linux 2 the folder is:

/opt/elasticbeanstalk/config/private/logtasks/bundle

The .ebextensions/mydaemon-logfiles.config should be:

files: 
  "/opt/elasticbeanstalk/config/private/logtasks/bundle/mydaemon-logs.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
       /var/mydaemon/deeperlogs/*.log

container_commands:
  append_deeperlogs_to_applogs:
    command: echo -e "\n/var/log/eb-docker/containers/eb-current-app/deeperlogs/*" >> /opt/elasticbeanstalk/config/private/logtasks/bundle/applogs

The mydaemon-logfiles.config also adds deeperlogs into applogs file. Without it deeperlogs will not be included in the download log zip bundle. Which is intresting, because the folder will be in the correct location, i.e., /var/log/eb-docker/containers/eb-current-app/deeperlogs/. But without being explicitly listed in applogs, it will be skipped when zip bundle is being generated.

I tested it with single docker environment (3.0.1).

The full log bundle successful contained deeperlogs with correct log data:

enter image description here

enter image description here

Hope that this will help. I haven't found any references for that. AWS documentaiton does not document this, as it is mostly based on Amazon Linux 1, not Amazon Linux 2.

over 4 years ago · Santiago Trujillo Report

0

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

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.

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.

over 4 years ago · Santiago Trujillo Report

0

As of 2021/11/05, I tried the accepted answer and various other examples including the latest official documentation on using the .ebextensions folder with *.config files without success.

Most likely something I was doing wrong but here's what worked for me. The version I'm using: Docker running on 64bit Amazon Linux 2/3.4.8

Simply, add a volume to your docker-compose.yml file to share your application logs to the Elastic Beanstalk log directory.

Example docker-compose.yml:

version: "3.9"
services:
  app:
    build: .
    ports:
      - "80:80"
    user: root
    volumes:
      - ./:/var/www/html
      # "${EB_LOG_BASE_DIR}/<service name>:<log directory inside container>
      - "${EB_LOG_BASE_DIR}/app:/var/www/html/application/logs" # ADD THIS LINE
    env_file:
      - .env

For more info, here's the documentation I followed.

Hopefully, this helps future readers like myself 👍

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!