- Newest
- Most votes
- Most comments
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
Hi,
You can configure an AWS cloudwatch alarm using the following steps to recieve email notifications if instance is running for an hour.
- Open the cloudwatch service.
- Click All alarms and the create alarm on the page.
- Select metric -> ec2 -> Per-instance metrics
- Select the ec2 instance with metric= CPUUtilization
- Click select metric.
- Statistic = "sum", Period = "1 hour"
- Threshold type ="static"
- Whenever CPUUtilization is... Greater than "0"
- Click next
- Select Alarm state trigger="In alarm"
- Under Send a notification to the following SNS topic , Create new topic and provide email address to which notification is to be sent.
- Click next and provide a name for this alarm.
- 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
Relevant content
- Accepted Answerasked a year ago
- AWS OFFICIALUpdated 3 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 months ago