Time of triggering the alarm.

0

how to trigger CloudWatch alarm for an EC2 instance which is running more than hour? I need to get notification if Instance is running for more than 1 hour.

asked a year ago567 views
2 Answers
0

Hi, did you envision to run a script shell at EC2 instance startup via user data: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-shell-scripts

This shell could sleep in background for 1 h and send the notification that you want with 'aws cloudwatch set-alarm-state' for example.

See https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudwatch/set-alarm-state.html

Another (more involving path) would be to use AWS SSM to do something equivalent

profile pictureAWS
EXPERT
answered a year ago
0

Hi,

You can configure an AWS cloudwatch alarm using the following steps to recieve email notifications if instance is running for an hour.

  1. Open the cloudwatch service.
  2. Click All alarms and the create alarm on the page.
  3. Select metric -> ec2 -> Per-instance metrics
  4. Select the ec2 instance with metric= CPUUtilization
  5. Click select metric.
  6. Statistic = "sum", Period = "1 hour"
  7. Threshold type ="static"
  8. Whenever CPUUtilization is... Greater than "0"
  9. Click next
  10. Select Alarm state trigger="In alarm"
  11. Under Send a notification to the following SNS topic , Create new topic and provide email address to which notification is to be sent.
  12. Click next and provide a name for this alarm.
  13. Click next and then create alarm.

You will start receiving email notifications. To test for a short span, select Period= 1 minute in step 6.

Hope this helps. If the solution works for you, your contribution to mark it answered will help others with similar use case.

Kind Regards, Prince Arora

profile picture
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions