[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# Telemetry Reporting\n\n| **Alpha**\n|\n|\n| This product or feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA products and features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n\nIntroduction\n------------\n\nThis page describes how to use the Service Control API v2 for telemetry\nreporting for [managed services](/service-infrastructure/docs/glossary#managed) that are integrated\nwith Service Infrastructure. It is intended for service producers who want to\ndeeply integrate their services with Google Cloud.\n\nService Infrastructure is a foundational platform for developers to produce, manage,\nsecure and\nconsume APIs and services. It uses a simple, generic service usage model:\na consumer consumes a service managed by a producer. All Google APIs and\n[Google Cloud APIs](/apis) use this model, since they are also\nbuilt on top of Service Infrastructure.\n\nWhen a consumer accesses a service, the service reports relevant telemetry\ndata to the platform, so both the consumer and the producer can observe\nthe access. With Service Infrastructure, this process is called telemetry reporting,\nwhich includes analytics, auditing, billing, logging, and monitoring.\n| **Note:** For terminology used in this page, see [API Glossary](/apis/design/glossary).\n\nService Control API v2\n----------------------\n\nThe Service Control API v2 provides a simple\n[`services.report`](/service-infrastructure/docs/service-control/reference/rest/v2/services/report)\nmethod that provides telemetry reporting to all services integrated with\nService Infrastructure. This method lets you do the following in a single method call:\n\n- Analytics\n- Auditing\n- Billing\n- Logging\n- Monitoring\n\nWhen a service reports telemetry data to the Service Control API, the data\nis distributed to the consumer, or the producer, or both, depending on the\nservice configuration. For more information about configuring telemetry, see\nthe logging and monitoring sections of\n[`google.api.Service`](https://github.com/googleapis/googleapis/blob/master/google/api/service.proto).\n\nIn order for a service to call the Service Control API, the producer must\nenable the Service Control API on the producer project, and the caller\nmust have proper permissions on the service. For more information, see\nCloud APIs [Getting Started](/apis/docs/getting-started) and\n[Service Control API Access Control](/service-infrastructure/docs/service-control/access-control).\n\n### Request attributes\n\nWhen a client accesses a service, the service needs to model the access\nin terms of a set of API requests, and describe each request using an\n[`AttributeContext`](https://github.com/googleapis/googleapis/blob/master/google/rpc/context/attribute_context.proto).\n\nTo report [API metrics](https://cloud.google.com/apis/docs/monitoring) using\nthe Service Control API, the service needs to call the\n[`services.report`](/service-infrastructure/docs/service-control/reference/rest/v2/services/report)\nmethod for each request with the following attributes. The Service Control API\nwill generate the API metrics and send them to [Cloud Monitoring](/monitoring).\n\nPerforming telemetry reporting\n------------------------------\n\nOnce you have deployed your service configuration to the Service Management\nAPI and your service is ready to serve requests from clients, you can\nbegin calling `services.report` for your deployed service. You should\ncall `services.report` to perform telemetry reporting after your\nservice receives a request.\n\nTo quickly experiment with the telemetry reporting, you can use the `gcurl`\ncommand to call the `services.report` method. See\n[Getting Started with the Service Control API](/service-infrastructure/docs/service-control/getting-started)\nfor the initial setup steps.\n\nThe following example shows you how to use `gcurl` command to call\n`services.report` over HTTP. \n\n```\ngcurl -d '{\n \"service_config_id\": \"latest\",\n \"operations\": [{\n \"origin\": {\n \"ip\": \"1.2.3.4\"\n },\n \"api\": {\n \"service\": \"endpointsapis.appspot.com\",\n \"operation\", \"google.example.endpointsapis.v1.Workspaces.GetWorkspace\",\n \"version\": \"v1\",\n \"protocol\": \"https\"\n },\n \"request\": {\n \"id\": \"123e4567-e89b-12d3-a456-426655440000\",\n \"size\": 50,\n \"time\": \"2019-07-31T05:20:00Z\",\n },\n \"response\": {\n \"size\": 100,\n \"code\": 200,\n \"time\": \"2019-07-31T05:20:02Z\",\n \"backend_latency\": \"0.007s\"\n },\n \"destination\": {\n \"region_code\": \"us-central1\"\n }\n \"resource\": {\n \"name\": \"projects/123/locations/us-central1/workspaces/default\"\n }\n }]\n}' https://servicecontrol.googleapis.com/v2/services/endpointsapis.appspot.com:report\n```\n\nIf successful, the response from the `services.report` method should be\nempty. If failed, the API error should contain detailed error information.\nFor more information about error handling, see\n[API Design Guide \\\u003e Errors](/apis/design/errors).\n\nFor production services, you should use one of Google-provided client libraries\nto call the Service Control API. Such libraries provide great usability\nand handle common functionality automatically, such as authentication.\nFor more information, see\n[Client Libraries Explained](/apis/docs/client-libraries-explained)."]]