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.

質問済み 1年前580ビュー
2回答
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
エキスパート
回答済み 1年前
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
回答済み 1年前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ