如何通过GCP API获取总VCPU计数

发布于 2025-01-18 11:48:07 字数 303 浏览 3 评论 0原文

我想调用GCP API来获取vCPU的总数。如果我的所有实例都使用 280 vCPU,我希望在响应中获得 280。 我可以使用 “/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus” 通过 API 指标获取 vCPU 限制,但不是当前的vCPU 计数。 是否有用于此目的的监控 API?

感谢帮助。 谢谢。

I would like to call GCP API call to get vCPU's total count. If all my instances use 280 vCPUs, I want to get 280 in the response.
I can get the vCPU limit via the API metrics using "/services/compute.googleapis.com/consumerQuotaMetrics/compute.googleapis.com%2Fcpus", but not the current vCPU count.
Is there a monitoring API for that purpose?

Help is appreciated.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼波传意 2025-01-25 11:48:07

由于 @guillaume blaquiere 目前无法使用 GCP API 来计算 vCPU。如果您认为有帮助,可以通过 Google 问题跟踪器 创建功能请求特征。

作为解决方法,您可以使用 Cloud Monitoring 并使用 绘制单个指标类型的图表

Metrics Explorer 中,您需要选择:

  • 资源类型: VM 实例
  • 指标: 预留 vCPU
  • 聚合器:

求和如下所示:

As @guillaume blaquiere currently there is no way to count vCPU using GCP API. You can create Feature Request via Google Issue Tracker if you think it could be beneficial feature.

As a workaround, you can use Cloud Monitoring and use Chart a single metric type.

In Metrics Explorer you would need to choose:

  • Resource type: VM Instance
  • Metric: Reserved vCPUs
  • Aggregator: sum

It would look like below:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文