Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini menjelaskan cara menggunakan Infrastruktur Layanan untuk memungkinkan layanan terkelola mengirim data penggunaan penagihan sehingga Penagihan Cloud dapat menagih konsumen layanan.
Misalnya, Anda dapat menentukan metrik yang disebut library.appspot.com/books/borrowed
untuk mengukur jumlah buku yang dipinjam oleh pelanggan dan menentukan unit penyimpanan
stok (SKU) dan harga untuk buku tersebut.
Service Control API menerima metrik, yang dikelompokkan, diagregasi, dan diteruskan ke Cloud Billing. Penagihan Cloud menyerap metrik ini dan membuat tagihan berdasarkan model harga yang telah ditentukan sebelumnya. Jika tidak ada model harga standar, Penagihan Cloud akan mengabaikan metrik penagihan. Untuk menentukan model harga, hubungi Google Cloud
Account Manager partner Anda.
Mengonfigurasi penagihan
Sebelum mengirim data penagihan ke Service Control API, Anda perlu
menentukan tiga informasi berbeda dalam
konfigurasi layanan:
Resource yang dipantau: Anda dapat mengumpulkan penggunaan penagihan untuk setiap resource. Resource yang dipantau memerlukan setidaknya satu kunci label
cloud.googleapis.com/location untuk menunjukkan lokasi penggunaan penagihan.
Metrik: Anda dapat melaporkan satu atau beberapa metrik. Setiap metrik mengukur
penggunaan jenis resource tertentu. Hanya metrik DELTA dengan nilai INT64 yang didukung untuk penagihan.
Konfigurasi penagihan: Memungkinkan Anda menentukan metrik yang akan dikirim ke
Penagihan Cloud.
Contoh konfigurasi layanan berikut menentukan satu metrik yang mengukur
jumlah buku yang dipinjam oleh pelanggan. Klien dapat memanggil metode
services.report untuk melaporkan nilai pada metrik. Lihat
billing.proto
untuk mengetahui detail konfigurasi penagihan.
Setelah mengonfigurasi pemantauan di
konfigurasi layanan
dan mengirimkan konfigurasi layanan menggunakan Service Management API, Anda dapat
memanggil Service Control API untuk melaporkan metrik. Contoh berikut
menggunakan perintah gcurl untuk mendemonstrasikan panggilan. Untuk mengetahui informasi tentang cara menyiapkannya, lihat Mulai Menggunakan Service Control API.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Reporting Billing Metrics\n\nThis page describes how to use Service Infrastructure to enable\n[managed services](/service-infrastructure/docs/glossary#managed) to send billing usage data so that\nCloud Billing can charge against [service consumers](/service-infrastructure/docs/glossary#consumer).\nFor example, you can define a metric called `library.appspot.com/books/borrowed`\nto measure the number of books borrowed by a customer and define a stock keeping\nunit (SKU) and price for it.\n\nThe Service Control API accepts metrics, which it batches, aggregates,\nand forwards to [Cloud Billing](/billing). Cloud Billing ingests these\nmetrics and generates bills based on the predefined price model. If there is no\npredefined price model, [Cloud Billing](/billing) simply disregards the\nbilling metrics. To define the price model, please contact your Google Cloud\npartner account manager.\n\nConfiguring billing\n-------------------\n\nBefore you send billing data to the Service Control API, you need to\nspecify three different bits of information in your\n[service configuration](/service-infrastructure/docs/service-management/reference/rpc/google.api#google.api.Service):\n\n- **Monitored resources** : You can collect billing usage for each\n resource. The monitored resources need at least one label key\n `cloud.googleapis.com/location` to indicate the location of the billing usage.\n\n- **Metrics**: You can report one or more metrics. Each metric measures the\n usage of a given type of resource. Only DELTA metrics with INT64 values are\n supported for billing.\n\n- **Billing configuration**: Lets you specify the metrics to be sent to\n Cloud Billing.\n\nThe following example service configuration defines one metric that measures the\nnumber of books borrowed by a customer. A client can invoke the\n`services.report` method to report values on the metric. See\n[billing.proto](https://github.com/googleapis/googleapis/blob/master/google/api/billing.proto)\nfor details on billing configuration. \n\n # library\n monitored_resources:\n - type: library.appspot.com/branch\n labels:\n - key: cloud.googleapis.com/location\n description: The cloud location.\n - key: library.appspot.com/city\n description: The city where the library branch is located in.\n\n # The metrics to be used.\n metrics:\n - name: library.appspot.com/books/borrowed\n metric_kind: DELTA\n value_type: INT64\n unit: '1'\n\n # The billing configuration.\n billing:\n consumer_destinations:\n - monitored_resource: library.appspot.com/branch\n metrics:\n - library.appspot.com/books/borrowed\n\nReporting billing metrics\n-------------------------\n\nOnce you have configured monitoring in the\n[service configuration](/service-infrastructure/docs/service-management/reference/rpc/google.api#google.api.Service)\nand pushed the service configuration using the Service Management API, you can\ncall the Service Control API to report metrics. The following example\nuses the `gcurl` command to demonstrate the call. For information on how to set\nthis up, see\n[Getting Started with the Service Control API](/service-infrastructure/docs/service-control/getting-started). \n\n $ gcurl -d \"{\n 'operations': [ {\n 'operationId': '8356d3c5-f9b5-4274-b4f9-079a3731e6e5',\n 'consumerId': 'project:library-consumer',\n 'startTime': '`date +%FT%T%:z`',\n 'endTime': '`date +%FT%T%:z`',\n 'labels': {\n 'cloud.googleapis.com/location': 'us-west1',\n 'library.appspot.com/city': 'Kirkland',\n },\n 'metricValueSets': [ {\n 'metricName': 'library.appspot.com/books/borrowed',\n 'metricValues': [ { 'int64Value': '10' } ]\n } ]\n } ]\n }\" https://servicecontrol.googleapis.com/v1/services/library.appspot.com:report"]]