How to track InsufficientInstanceCapacity from AWS EC2?

Viewed 556

I have a Kubernetes cluster that relies on AWS EC2 spot requests. I sometimes have this failure message from the aws auto-scaling group:

Could not launch Spot Instances. InsufficientInstanceCapacity - There is no Spot capacity available that matches your request. Launching EC2 instance failed.

I knew the downfall of using spot requests and that's not why I am here.

I'd like to track this kind of failed activity from my auto-scaling group and I did not find anything inside CloudWatch.

Is there any "legit" way of doing this? The final aim is to have an alert where AWS does not have capacity for my instance request(s) so I can act appropriately.

1 Answers

I came across this question when I was looking for the same thing, and now I have found an answer!

You can detect this event by creating a Cloud Trail that logs management events for your account, and looking for an event where the EventName = RunInstances, and the ErrorCode field is populated.

I have seen this particular event come through as ErrorCode: Server.InsufficientInstanceCapacity.

There are a variety of ways to consume and alert on the Cloud Trail logs, including CloudWatch.

Related