How to set the low memory alarm for AWS EC2 instance, S3 bucket?

Viewed 1358

I am using AWS EC2 for deployment of the dropwizard server code. We recently came across a case where the instance was stopped automatically. On investigation we found that it's whole memory was consumed we saw what consumed the memory mostly were backup files & log files. We removed those & restarted the server it is working well.

To avoid such behavior in future we thought of making use of ClaudWatch alarms provided by the AWS, but the parameters for alarm for EC2 are more of disk throughput, Network related not the diskspace related.

EC2 monitoring.

They suggest having cloud watch agent to be installed on actual instance.

In RDS there is memory alarm type which gets triggered on if memory remains less than some predefined criterion.

For EC2 instance, S3 bucket, Do we have any cloud watch alarm type or any other tool which will trigger a notification on emails when instance is low on memory?

Note: S3 provides object count alarms but couldn't find any specific to low memory.

Update:

Comment by Michael suggests that "There are two problems, here. EC2 instances do not stop when they run out of "memory" (nor storage, which is what you are actually describing). This does not happen. Also, bucket storage is unlimited."

There could be two possibilities instance may have stopped due to other reasons, but when we investigated the added storage to an instance which was 8GB got full. For S3 as he suggested there no limit how much can be stored [ Hence the couldwatch dashboard may be showing object count, not actual memory consume but is there any way that when S3 consumes a certain amount of files ( In MBs or GBs ) on the AWS we may get notifications ]

2 Answers

As you mentioned you need to put monitoring script or CloudWatch agent on EC2 instance to export memory usage or disk usage and attach alert to it - see https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/mon-scripts.html

S3 is about storing blob files - you don't need to care about memory usage in that service as that's handled under-hood by AWS so that's why you don't have access to any memory related metric.

Depending on your EC2 instance type you can configure those kinds of alarms. Memory, Disk-space, CPU utilization relates to OS metrics. There are various tools too to monitor those for example : Nagios Or else you can setup your own custom monitoring via email if instances are Unix/AMI Set up cron jobs and execute the monitoring shell scripts --> disk specific, CPU etc and set up email notification targeting your email addresses.

Related