简体   繁体   English

在AWS Cloudwatch中显示EC2实例计数

[英]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. 我正在尝试在Cloudwatch中创建一个图表,以显示我正在运行的所有实例,以及按需量,现货量或预留量的实例。 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? 有谁知道使用Cloudwatch或其他服务为此创建图表的最简单方法?

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. 所有EC2指标都是实例级别的,这意味着您必须选择要显示其指标的实例。

You could write code to do this, executing the DescribeInstances API call and aggregating by whatever fields you want. 您可以编写代码来执行此操作,执行DescribeInstances API调用并按所需的任何字段进行汇总。 Run this in a Lambda, and trigger the Lambda from a scheduled CloudWatch event, and you've got your metrics. 在Lambda中运行此代码,然后从计划的CloudWatch事件中触发Lambda,您便拥有了指标。

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. 根据所需的详细程度,可以使用实例类型,子网或VPC ID等维,以及它是否是竞价型实例。 Beware, that you'll be charged $0.30 per month for each combination of dimensions. 请注意,每个尺寸组合每月都会向您收取$ 0.30的费用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM