Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, você aprende a usar a Service Infrastructure a fim de permitir que os serviços gerenciados enviem dados de uso de faturamento para que o Faturamento do Cloud cobre os consumidores de serviço.
Por exemplo, você pode definir uma métrica chamada library.appspot.com/books/borrowed para medir o número de livros emprestados por um cliente e definir uma unidade de manutenção de estoque (SKU, na sigla em inglês) e seu preço.
A API Service Control aceita métricas que ela armazena em lote, agrega e encaminha ao Cloud Billing. O Cloud Billing ingere essas métricas e gera cobranças com base no modelo de preço predefinido. Se não houver um modelo de preço predefinido, o Faturamento do Cloud simplesmente ignora as métricas de faturamento. Para definir o modelo de preço, entre em contato com o Google Cloud
gerente de contas do parceiro.
Como configurar o faturamento
Antes de enviar dados de faturamento à API Service Control, você precisa especificar três tipos diferentes de informações na sua configuração de serviço:
Recursos monitorados: é possível coletar o uso de faturamento de cada recurso. Os recursos monitorados precisam de pelo menos uma chave de rótulo cloud.googleapis.com/location para indicar o local do uso da cobrança.
Métricas: você pode relatar uma ou mais métricas. Cada métrica avalia o uso de um determinado tipo de recurso. Somente as métricas DELTA com valores INT64 são aceitas para faturamento.
Configuração de faturamento: permite especificar as métricas a serem enviadas para o Cloud Billing.
No exemplo de configuração de serviço a seguir, definimos uma métrica que computa o número de livros emprestados para um cliente. Um cliente pode chamar o método services.report para relatar valores na métrica. Consulte billing.proto para mais detalhes sobre a configuração de faturamento.
Depois de configurar o monitoramento na configuração do serviço e enviar a configuração por push com a API Service Management, você pode chamar a API Service Control para relatar métricas. O exemplo a seguir usa o comando gcurl para demonstrar a chamada. Para informações sobre como fazer a configuração, consulte
Primeiros passos com a API Service Control.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-09-03 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"]]