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.

preguntada hace un año580 visualizaciones
2 Respuestas
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
EXPERTO
respondido hace un año
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
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas