3

我可以按实例名称查看 GCP 计费吗?(不是按类型)我正在尝试按实例名称过滤 GCP 计费,这可能吗?我只成功按 GCP Compute Engine 和实例类型(n1-standard)等过滤...

我正在尝试以编程方式将与 GCP 计算实例关联的 machineType 与相应的计费 SKU 匹配,但无法找到直接关联的密钥。例如,下面是 machineType API 的响应:

{
 "kind": "compute#machineType",
 "name": "n1-standard-32",
 "description": "32 vCPUs, 120 GB RAM",
 "guestCpus": 32,
 "memoryMb": 122880,
 "imageSpaceGb": 0,
 "maximumPersistentDisks": 128,
 "maximumPersistentDisksSizeGb": "65536",
 "zone": "us-east1-b",
 "isSharedCpu": false
}

以下是来自 cloudbilling API 的相应 SKU:

  "name": "services/XXXX/skus/XXXX",
  "skuId": "XXXX",
  "description": "Standard Intel N1 32 VCPU running in Americas",
  "category": {
    "serviceDisplayName": "Compute Engine",
    "resourceFamily": "Compute",
    "resourceGroup": "N1Standard",
    "usageType": "OnDemand"
  },
  "serviceRegions": [
    "us-central1",
    "us-east1",
    "us-west1"
  ],
  "pricingInfo": [
    {
      "summary": "",
      "pricingExpression": {
        "usageUnit": "h",
        "usageUnitDescription": "hour",
        "baseUnit": "s",
        "baseUnitDescription": "second",
        "baseUnitConversionFactor": 3600,
        "displayQuantity": 1,
        "tieredRates": [
          {
            "startUsageAmount": 0,
            "unitPrice": {
              "currencyCode": "USD",
              "units": "1",
              "nanos": 520000000
            }
          }
        ]
      },
      "currencyConversionRate": 1,
      "effectiveTime": "2018-02-22T12:00:16.647Z"
    }
  ],
  "serviceProviderName": "Google"

计费 SKU 中似乎没有值为 n1-standard-32 的字段。我们如何将这两者联系在一起,就像这个页面看起来一样:https ://cloud.google.com/compute/pricing ?

4

1 回答 1

0

您可以创建标签并添加到您的实例中,以获得每个实例的费用明细。需要在每个实例上添加此标签,添加后,您将能够通过按标签对其进行排序,在计费报告中查看每个实例的费用。

创建和管理标签可以在这里找到

您可以使用资源管理器 API 并执行请求,例如

POST https://cloudresourcemanager.googleapis.com/v1beta1/projects

{
 "labels": {
  "color": "red"
 },
 "name": "myproject",
 "projectId": "our-project-123"
}

您还可以使用gcloud 命令为您的 Compute Engine 实例添加和编辑标签

于 2019-11-13T09:11:43.830 回答