如何通过API获取AWS VCPU的利用率数
我想通过 GO API 获取该区域中所有正在运行的实例使用的 AWS VCPU 数量,这样我可以在创建新实例之前运行一些预检检查,以查看是否有足够的 VCPU 可用,而无需增加配额。
换句话说,如果我们查看控制台,我们可以看到运行按需标准(A、C、D、H、I、M、R、T、Z)实例服务配额,显示已应用配额值列,指示当前 VCPU 的限制。如果单击此字段,您可以看到“利用率”字段,其中显示已使用的 VCPU。这就是我所需要的。
谢谢!
I would like to get the number of AWS VCPU's used by all running instances in the region via GO API, so I can run some preflight checks before I create new instances, to see if there are enough VCPU's available, without increasing the quota.
In other words, if we look at the console we can see that Running On-Demand Standard (A, C, D, H, I, M, R, T, Z) instances service quota, shows Applied quota value column that indicates the current VCPU's limit. If you click on this field, you can see the 'Utilization' field that shows the used VCPU's. This is what I need.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了了解此信息的可用位置,我研究了服务配额 AWS 服务。
aws service-quotas list-service
命令列出服务代码,例如:因此,Amazon EC2 的服务代码是
ec2
。接下来,我使用
aws service-quotas list-service-quotas --service-code ec2
列出了该服务的配额。在我发现的输出中:这似乎与管理控制台中显示的配额相匹配。
然后我注意到
UsageMetric
信息看起来像 Amazon CloudWatch 指标:然后我转到 Amazon CloudWatch,单击所有指标并输入搜索词
使用标准< /code>:
啊哈!
Standard/OnDemand
指标出现了!选择该复选框后会显示一个图表:
此指标与显示的
利用率
数字相匹配在服务配额页面中。底线
服务配额指标可通过 Amazon CloudWatch 获取。您可以使用标准 API 调用来检索这些指标,或通过 Amazon CloudWatch Metrics 管理控制台访问它们。您还可以针对这些指标创建警报,以便在它们超出所需限制时通知您。
To discover where this information was available, I looked into the Service Quotas AWS service.
The
aws service-quotas list-service
command lists the service codes, such as:So, the service code for Amazon EC2 is
ec2
.Next, I listed the quotas for this service using
aws service-quotas list-service-quotas --service-code ec2
. Amongst the output I found:This seemed to match the quota displayed in the Management Console.
I then noticed that the
UsageMetric
information looked like an Amazon CloudWatch metric:I then went to Amazon CloudWatch, clicked All metrics and entered a search term of
usage standard
:Aha! The
Standard/OnDemand
metric appeared!Selecting the checkbox then showed a chart:
This metric matches the
Utilization
figure shown in the Service Quotas page.Bottom line
Service Quota metrics are available through Amazon CloudWatch. You can use standard API calls to retrieve these metrics, or access them through the Amazon CloudWatch Metrics management console. You can also Create Alarms on these metrics to notify you when they exceed desired limits.