Create new AWS alert on startup for monitoring memory - best way

0

Afternoon all, I found a few old threads (9 years old) saying to use an SNS topic, etc. but my goal is simple. I have an autoscaling group, and when a new machine starts, I have cloudwatch graphs adding those nicely, but also want to have a cloudwatch alert created to monitor the mem_used_percent and if its > 80% alert (maybe reboot or just send to an SNS topic).

So as I said, the old ways are quite deep for something I think should be easier now. These machines as I said are all in an auto scale group, so I could make a new template and just add something to that image on boot, or is there a newer way to get this easier?

Thanks all

질문됨 3달 전115회 조회
2개 답변
3
수락된 답변

Hi,

The solution to your problem is to use EventBridge auto-scaling events: https://docs.aws.amazon.com/autoscaling/ec2/userguide/automating-ec2-auto-scaling-with-eventbridge.html

In particular, have a look at https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-event-reference.html

These events from EventBridge will trigger a Lambda (and then may a StepFunction) in which you can do all you need and already know how to do ("I know how to setup the alert options, reboot, run a lambda function, ")

Best,

Didier

profile pictureAWS
전문가
답변함 3달 전
profile picture
전문가
검토됨 2달 전
  • Hi Lraymond, thanks for accepting my answer!

0

Collect the memory usage metrics using CloudWatch Agent https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html

And then have a look at using Systems Manager for automating the actions when this breaches the threshold https://aws.amazon.com/blogs/mt/automating-amazon-cloudwatch-alarms-with-aws-systems-manager/

profile picture
전문가
Steve_M
답변함 3달 전
  • The CW agent is already installed on that launch template so I can go to any new machine and see. The issue is this is in an auto-scaling group so if a machine fails, or a new one is added, yes it's already collecting, but I need to manually add that alarm. The point in the original thread is to know the best path when you change that scaling group from 2 to 3 servers for example, the new server starts, pulls down the latest code from code-deploy, all is good, BUT now I want to have that machine added to the cloudwatch alerts automatically. I know how to setup the alert options, reboot, run a lambda function, etc. the issue is how does the new EC2 instance create an alert in cloudwatch alerts. An example as I said here here - https://stackoverflow.com/questions/25002240/aws-cloudwatch-alarm-on-startup-of-new-ec2-instance however that is 9+ years old, there must be a better / automated way then that.

  • It's a little bit of work, however all makes sense following that doc ...

    Thanks for the direction and help

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠