Google cloud platform 如何通过GCP Api检查GCP中承诺使用折扣下计算资源的使用情况?
我是GCP的新手,这里有一个一般性问题 如何通过GCP Api在承诺使用折扣的情况下检查计算资源(如vCPU/内存)的使用情况?我已经做了很多研究,我知道我可以通过这样做得到我在特定承诺使用折扣下购买的计算资源总量Google cloud platform 如何通过GCP Api检查GCP中承诺使用折扣下计算资源的使用情况?,google-cloud-platform,google-api,google-api-python-client,Google Cloud Platform,Google Api,Google Api Python Client,我是GCP的新手,这里有一个一般性问题 如何通过GCP Api在承诺使用折扣的情况下检查计算资源(如vCPU/内存)的使用情况?我已经做了很多研究,我知道我可以通过这样做得到我在特定承诺使用折扣下购买的计算资源总量 from pprint import pprint from googleapiclient import discovery from oauth2client.client import GoogleCredentials credentials = GoogleCreden
from pprint import pprint
from googleapiclient import discovery
from oauth2client.client import GoogleCredentials
credentials = GoogleCredentials.get_application_default()
service = discovery.build('compute', 'v1', credentials=credentials)
# Project ID for this request.
project = 'my-project' # TODO: Update placeholder value.
# Name of the region for this request.
region = 'us-east1' # TODO: Update placeholder value.
request = service.regionCommitments().list(project=project, region=region)
while request is not None:
response = request.execute()
这可以为我提供此承诺使用折扣下的计算资源总量:
{'category': 'MACHINE',
'creationTimestamp': '2020-07-24T12:06:09.460-07:00',
'endTimestamp': '2021-07-25T00:00:00.000-07:00',
'id': '2837180167266668494',
'kind': 'compute#commitment',
'name': 'commitment-shared-20200724',
'plan': 'TWELVE_MONTH',
'region': 'https://www.googleapis.com/compute/v1/projects/digital-billing-cad/regions/us-east1',
'resources': [{'amount': '1190', 'type': 'VCPU'},
{'amount': '3510272', 'type': 'MEMORY'}],
'selfLink': 'https://www.googleapis.com/compute/v1/projects/digital-billing-cad/regions/us-east1/commitments/commitment-shared-20200724',
'startTimestamp': '2020-07-25T00:00:00.000-07:00',
'status': 'ACTIVE',
'statusMessage': 'The commitment is active, and so will apply to current '
'resource usage.'}
Process finished with exit code 0
然而,我真的很难在这个承诺使用折扣下找到该计算资源的使用情况。你有没有想过如何找到它?多谢各位