How to get total vCPU's count via GCP API

1.4k views Asked by At

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.

1

There are 1 answers

0
PjoterS On

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: