deef
deef

Reputation: 4770

Show EC2 instance counts in AWS Cloudwatch

I'm trying to create a chart in Cloudwatch that shows all the instances I have running, and how many are on-demand versus spot versus reserved. I've been looking for hours and can't seem to find any way to do this.

Does anyone know the easiest way to create a chart for this, using Cloudwatch or some other service?

Upvotes: 8

Views: 5868

Answers (1)

guest
guest

Reputation: 637

There aren't any predefined metrics that would give you this information. All EC2 metrics are instance-level, which means that you must select the instance(s) that you want to display metrics for.

You could write code to do this, executing the DescribeInstances API call and aggregating by whatever fields you want. Run this in a Lambda, and trigger the Lambda from a scheduled CloudWatch event, and you've got your metrics.

Depending on how much detail you want, you could use dimensions such as instance type, subnet, or VPC ID, as well as whether or not it's a spot instance. Beware, that you'll be charged $0.30 per month for each combination of dimensions.

Upvotes: 6

Related Questions