10

I have a docker image through which I make an aws batch job definition. Within the docker I am printing some statements. The job runs and there's a success message. But the logs aren't there in Cloudwatch. It says that no events found. Not even the start and endtime of the job.

Cloudwatch logs

I have set up the environment variable ECS_AVAILABLE_LOGGING_DRIVERS = awslogs as well but I still don't see any logs.

What additional configuration are required ?

Piyush Dugar
  • 101
  • 1
  • 5
  • Unlike Lambda, which logs start/end of the job to CloudWatch Logs, Batch will only log output from the container to CloudWatch Logs. Likely your job is simply not logging to STDOUT. You shouldn't have to set any additional configuration to make logs happen - Batch should handle that. – Luke Waite Sep 02 '18 at 21:24
  • @LukeWaite OP says that they are printing statements in their docker, this suggests they are either logging to STDOUT or STDERR, both of which should go to CloudWatch. – Aron Aug 28 '20 at 07:14
  • What about permissions? Does your docker has permissions to write to CW logs? Is it running on an instance or ECS? – Marcin Aug 28 '20 at 08:23

1 Answers1

1

For Using CloudWatch Logs with container instances you need the following:

  • CloudWatch Logs IAM Policy
  • Installing and configuring the CloudWatch agent on your Container

the steps could be found here

LinPy
  • 16,987
  • 4
  • 43
  • 57
  • 1
    The ECS containers were setup by AWS Batch and the IAM Policy was added by the wizzard. – Aron Aug 28 '20 at 11:02
  • 1
    you still need to install and configure the cloudwatch agent in your docker image – LinPy Aug 28 '20 at 11:04
  • 1
    see this also https://aws.amazon.com/blogs/devops/send-ecs-container-logs-to-cloudwatch-logs-for-centralized-monitoring/ – LinPy Aug 28 '20 at 11:09
  • 1
    Turns out the problem was that log shipping was delayed by a few hours. Will create a new question based on that...awarding you the rep anyway, since it is probably the correct answer. – Aron Sep 04 '20 at 16:22
  • I also have an issue where a batch job fails, and it takes from several minutes to at least half an hour for the logs to appear in cloudwatch. Is there any way to hasten this process? – alexander zak Dec 08 '22 at 07:28