[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-11。"],[],[],null,["# Best practices for usage labeling\n\nFor usage-based SaaS products, Google Cloud Marketplace attributes usage to a single\nGoogle Cloud project, specified by the `usageReportingId` field. In some\nscenarios, a SaaS product might be shared broadly within a customer's\norganization and used across many customer projects. To enable support for more\nspecific cost attribution, we recommend that usage-based SaaS products include\nthe optional `userLabels` field on their usage report\n[operation](/service-infrastructure/docs/service-control/reference/rest/v1/Operation).\n\nIf your service already supports a concept of\n[resource labels](/resource-manager/docs/creating-managing-labels), we recommend\nthat you forward those labels in your usage reports. Labels must conform to the\n[syntax requirements](/resource-manager/docs/creating-managing-labels#requirements).\n\nUsage labels\n------------\n\nCloud Marketplace reserves the following labels. You can use these labels\nto identify additional context for usage within your service platform. We\nrecommend that you include these labels in your usage reports by default.\n\nLabels are forwarded to Cloud Billing [cost management](/cost-management)\ntools, including [cost reports](/billing/docs/how-to/reports) and\n[billing exports](/billing/docs/how-to/export-data-bigquery).\n\nUsage labeling example\n----------------------\n\nFor this example, imagine your organization offers a storage product called\n**SaaS Storage Solutions**.\n\nA customer, Carl, has purchased your storage offering for their\nGoogle Cloud project `e-commerce-website`, to host the `user_profiles_db`\nand `products_db` databases for their ecommerce website:\n\n- `user_profiles_db` contains information about users that visit Carl's site.\n- `products_db` contains information about products that Carl sells on their site.\n\nIf you want to provide Carl a detailed cost breakdown of their usage, you can\nuse the `userLabels` key-value pair to report the cost of usage for each\ndatabase separately.\n\nFor example, to report the cost attributed to Carl's `products_db` storage\nusage, you could send the following report, which indicates that Carl's\n`products_db` storage is costing them 100 units: \n\n operation = {\n 'operationId': '\u003cUUID\u003e',\n 'operationName': 'db-total-storage',\n 'consumerId': 'project:carl_website',\n 'startTime': '\u003cTimestamp\u003e',\n 'endTime': '\u003cTimestamp\u003e',\n 'metricValues': [{\n 'int64Value': 100,\n }],\n 'userLabels': {\n 'cloudmarketplace.googleapis.com/container_name': 'e-commerce-website',\n 'cloudmarketplace.googleapis.com/resource_name': 'products_db'\n }\n }\n\n service.services().report(\n serviceName=service_name, body={\n 'operations': [operation]\n }).execute()\n\nIn this example, `service_name` is the Project ID of Carl's Google Cloud\nproject.\n\nFor a more detailed example of using `userLabels`, refer to the\n[SaaS codelab](https://developers.google.com/gcp-marketplace-saas)."]]