Score:0

How to get live logs sent from ECS to AWS cloudwatch

gr flag

I run containers in ECS on python docker image which has ssh installed because sometimes I need to login to the container.

Whatever logs are outputted using print in the python script show up in the log group for the container enter image description here

The issue is it's not live log being sent. It is in batches. Container runs for 40 hours and the logs get sent in batches with hours of delay in between

Is there a way to ensure the logs sent from containers are live rather than in batches?

The Dockerfile I use has the following structure

FROM python:3.7

RUN apt-get update && \
    apt-get install -y cron curl dnsutils htop iputils-ping openssh-server lsof nano net-tools procps vim && \
    apt-get clean

...

EXPOSE 22

WORKDIR /usr/src/app

COPY . .

RUN pip install --no-cache-dir -r requirements.txt

CMD service ssh start && python script.py

Task definition has the logging enabled

            "logConfiguration": {
                "logDriver": "awslogs",
                "options": {
                    "awslogs-group": "/ecs/my-python-td",
                    "awslogs-region": "us-west-1",
                    "awslogs-stream-prefix": "ecs"
                }
            }
jp flag
Output buffering? https://serverfault.com/questions/940281/why-doesnt-my-docker-actually-log-anything
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.