简体   繁体   中英

How to get 'Current usage percentage' for CPU's via Service Usage API

On the quotas page, there are a few things listed for different Quotas.

I am focusing on CPU's Quota. I can get the Dimensions and the Effective Limit. But could not find anything in the API for getting 'Current usage percentage'.

Basically, I need to know what is my current CPU's usage for a specific region.

Help is appreciated.

There is a way of getting the actual number of resources used in a certain region by using a serviceruntime.googleapis.com/quota/allocation/usage metric .

It won't give you a percentage but a number of VM's, CPU's etc.

Have a look at my other answer to a very similar question describing how it's done.

In essence you need to use a metric I mentioned and then you can call the Cloud Monitoring API to get the number (let's call it "x"). You still need to get the actual quota value (lets call it "y") and calculate x/y and then you will get a percentage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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