- Mais recentes
- Mais votos
- Mais comentários
Hello
when creating the auto-scaling launch configuration, you can set the user data with the CLI command to create the alarm. The user data gets executed when the instance is created
https://docs.aws.amazon.com/autoscaling/ec2/APIReference/API_CreateLaunchConfiguration.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-api-cli
hope this helps
RT
Hello
for Cloudformation, you can create the instance and the alarm in the same template. Here is the template on how to create the alarm notice that you need the instance ID which shouldnt be a problem if you have both in the same template
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/quickref-cloudwatch.html#cloudwatch-sample-cpu-utilization-alarm
the problem with the autoscale group is that the alarm requires the actual instance ID which it cannot get directly. Here is something i found online in where the alarm is created in the userdata
https://stackoverflow.com/questions/25002240/aws-cloudwatch-alarm-on-startup-of-new-ec2-instance
I havent tried but it might work. there is also some discussion on that page.
hope this helps,
RT
Thank you for your reply. I already had a look at the link.
There are two suggestions
Run a script when an instance is created. This can be done, if I launch the instance, but I am not sure that it would work if the autoscaling group creates new instance (until I trigger the script by a CloudWatch alert when an instance is added/removed).
Second suggestion was to bake the alert into the AMI. I am not sure how this can be done. I can add custom metrics to the base AMI but not sure how I can add custom alerts
Conteúdo relevante
- AWS OFICIALAtualizada há 3 anos
- AWS OFICIALAtualizada há 7 meses
- AWS OFICIALAtualizada há 5 anos
- AWS OFICIALAtualizada há 2 meses