'ECS TASK alerts on OutOfMemory

If a ECS container is out of memory or is in hung state or stopped thought is gets restarted. is there a way to I se up alarms on top of that using cloudwatch or directly from the task logs? because the OutOfMemory error that I saw in Task logs was not in cloudwatch logs and later the stopped task got removed.

error I see in stopped task STOPPED (OutOfMemoryError: Container killed due to memory u)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source