當用戶端向 Cloud Service Mesh 回報,從來源區域傳送跨區域流量至一或多個目的地區域時,就會產生這類記錄訊息。
查看指標
Cloud Service Mesh 會將三個指標匯出至 Cloud Monitoring:xDS API 已連線串流、要求次數和依區域劃分的請求次數。xDS API 已連線串流:代表已連線至控制平面的用戶端數量;要求次數:代表傳送至後端服務的請求次數,並依來源區域、目的地區域和要求狀態分組。「依區域劃分的請求計數」:指出傳送至後端服務的請求數量,並依來源區域、目的地區域和要求狀態分組。如要查看這些指標,請使用 Metrics Explorer。
[[["容易理解","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,["# Control plane logging and monitoring\n====================================\n\n| **Note:** This guide only supports Cloud Service Mesh with Google Cloud APIs and does not support Istio APIs. For more information see, [Cloud Service Mesh overview](/service-mesh/docs/overview).\n\nThis document demonstrates how to use [Cloud Logging](/logging/docs) and\n[Cloud Monitoring](/monitoring/docs) to view logs and metrics for the\nCloud Service Mesh control plane.\n\nUsing a service mesh gives you the ability to observe traffic to and from\nservices, which allows for richer monitoring and debugging without code changes\nin the service itself. Log entries can provide important information for\ntroubleshooting your service mesh, including records of successful connections\nand disconnections, error reports for misconfigured clients, and alerts\nabout API resource conflicts.\n\nUse cases\n---------\n\nThe following are three use cases for control plane logging and monitoring:\n\n- **Cloud Logging for Cloud Service Mesh control plane**: You can securely store, search, analyze, and set alerts on all of your Cloud Service Mesh logging data and events using all the built-in features of Logging. Cloud Service Mesh exports logs to Logging when an Envoy or gRPC client connects or disconnects, as well as when it detects configuration issues.\n- **Cloud Monitoring for Cloud Service Mesh control plane**: Cloud Service Mesh exports a key metric indicating the number of clients connected to the Cloud Service Mesh control plane to Monitoring. You can set up a dashboard in Monitoring and visualize this metric in real time to monitor the health of the mesh as clients connect and disconnect. This also lets you set up an SLO for your mesh.\n- **Troubleshoot issues immediately**: Cloud Service Mesh exports telemetry to Logging and Monitoring by default. No additional setup is necessary to configure logging and monitoring, enabling you to troubleshoot issues at any time, including when you are setting up the mesh for the first time.\n\nView logs\n---------\n\nTo view Cloud Service Mesh logs, use the\n[Logs Explorer](/logging/docs/view/logs-explorer-interface). The following\nsection presents an example query to view Cloud Service Mesh logs, but you can\nuse the previous link to create your own query.\n\n1. In the Google Cloud console, go to the **Logs Explorer** page.\n\n [Go to the Logs Explorer](https://console.cloud.google.com/logs/query)\n2. In the **Resource** list,\n - If you use the service routing APIs, select `Gateway Scope` or `Mesh`.\n - If you use the older APIs, select `GCE Network`.\n3. In the **Log name** list, select `trafficdirector.googleapis.com/events`.\n4. Click **Run query**.\n\n### Cloud Service Mesh log entry fields\n\n### Example log entries\n\nView metrics\n------------\n\nCloud Service Mesh exports three metrics to Cloud Monitoring:\n**xDS API Connected Streams** , **Request count** , and **Request count by zone** .\n**xDS API Connected Streams** indicates the number of clients that are\nconnected to your control plane; **Request count** indicates the number of\nrequests sent to a backend service, grouped by source region, destination\nregion, and request status. **Request count by zone** indicates the number\nof requests sent to a backend service, grouped by source zone, destination\nzone, and request status. To view these metrics, use the\n[Metrics Explorer](/monitoring/charts/metrics-explorer).\n\nTo view Cloud Service Mesh metrics, do the following:\n\n1. In the Google Cloud console, go to the **Metrics Explorer** page.\n\n [Go to the Metrics Explorer](https://console.cloud.google.com/monitoring/metrics-explorer)\n2. In the **Resource type** list, select a resource.\n - If you use the service routing APIs, select `Gateway Scope` or `Mesh`.\n - If you use the older APIs, select `Network`.\n3. In the **Metric** list, select `connected_clients`.\n4. Return to the **Resource type** list, and then select `Compute Engine Backend\n Service`.\n5. In the **Metric** list, select either `Request count` or `Request count by zone`.\n\nAlternatively, you can use a query to view the cross-region request count:\n\n1. Select **MQL**.\n2. In the field, enter the following example query: \n\n ```\n fetch gce_backend_service\n | metric 'trafficdirector.googleapis.com/xds/server/request_count'\n | filter ( ne(metric.source_region, metric.destination_region))\n | align rate(1m)\n | every 1m\n | group_by [metric.source_region, metric.destination_region, resource.backend_service_id],\n [value_request_count_aggregate: aggregate(value.request_count)]\n ```\n3. Click **Run query**.\n\nSet up logs-based metrics and alerts\n------------------------------------\n\nThe following steps require that you set up logs-based metrics. For more\ninformation about setting up logs-based metrics, see the\n[overview](/logging/docs/logs-based-metrics#viewing).\n\nYou can configure alerts to notify you when user-specified messages appear in\nyour included logs. These alerts can notify the operator when something\nunexpected occurs. For example, if a change in Cloud Service Mesh configuration\nresults in API resource conflicts, you can receive an alert on the error\nmessage. To set up alerts on your log-based metrics, see\n[Configure charts and alerts](/logging/docs/logs-based-metrics/charts-and-alerts#alert-on-lbm)."]]