Missing log lines when writing to cloudwatch from ECS Docker containers

后端 未结 4 1055
暗喜
暗喜 2021-02-08 10:12

(Docker container on AWS-ECS exits before all the logs are printed to CloudWatch Logs) Why are some streams of a CloudWatch Logs Group incomplete (i.e., the Fargate Docker Conta

4条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-08 10:32

    I observed this as well. It must be an ECS bug?

    My workaround (Python 3.7):

    import atexit
    from time import sleep
    
    atexit.register(finalizer)
    
    def finalizer():
        logger.info("All tasks have finished. Exiting.")
        # Workaround:
        # Fargate will exit and final batch of CloudWatch logs will be lost
        sleep(10)
    
    

提交回复
热议问题