Cloud Service Mesh 與 Service Directory 整合後,偵錯作業會變得更加複雜。在貴商家中,服務消費者和服務生產者可能屬於不同團隊或機構。為協助您偵錯這類問題,Cloud Service Mesh 整合了 Cloud Logging 和 Cloud Monitoring。
例如:
您有一個使用 Cloud Service Mesh 進行應用程式網路連線的checkout服務。
服務目錄中有一項 payment 服務,由其他團隊 (服務供應商) 擁有及維護。
您想從 checkout 服務呼叫 payment 服務,因此在 Cloud Service Mesh 中建立新的後端服務。這個後端服務會使用 Service Directory 進行服務探索,並附加至 payment 服務。
在這個模型中,服務供應商可能會想刪除或修改 Service Directory 中代管的payment服務。由於他們擁有payment服務,因此有權進行這類變更。但如果刪除 payment 服務,服務探索功能就會失效。
記錄
當 Cloud Service Mesh 解析附加至 Service Directory 服務的後端服務時,會從 Service Directory 取得端點清單。如果服務已從 Service Directory 刪除,Cloud Service Mesh 就不會取得任何端點。在這種情況下,系統會在 Cloud Logging 中新增記錄項目。記錄項目包含下列資訊:
後端服務名稱
Service Directory 名稱
訊息:Service Directory returned 0 endpoints for this service.
以利解決問題。你也可以設定快訊,主動接收通知。
監控
與記錄檔案例類似,Cloud Service Mesh 會與 Monitoring 整合,產生指標。Cloud Service Mesh 會為每個後端服務,在 Cloud Monitoring 中新增下列指標:
後端服務名稱
與這個後端服務相關聯的端點數量,這些端點會與 Cloud Service Mesh 的用戶端共用
Cloud Service Mesh 用戶端無法將流量傳送至沒有端點的後端服務。
Google Cloud 控制台
如果刪除服務目錄服務,且該服務的附件存在於 Cloud Service Mesh 後端服務中,Google Cloud 控制台會顯示警告:The attached
Service Directory service could not be found.
[[["容易理解","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,["# Observability and debugging with Service Directory\n==================================================\n\n|\n| **Preview**\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| **Deprecated:** Cloud Service Mesh's integration with Service Directory is going to be deprecated. Creating new service binding resources will be disabled.\n\nCloud Service Mesh's integration with Service Directory introduces new\ncomplexities in debugging. Within your business, service consumers and\nservice producers might belong to different teams or organizations. To help you\ndebug such issues, Cloud Service Mesh integrates with Cloud Logging and\nCloud Monitoring.\n\nFor example:\n\n- You have a `checkout` service that uses Cloud Service Mesh for application networking.\n- There's a `payment` service in Service Directory that a different team (the *service producer*) owns and maintains.\n- You want to call on the `payment` service from the `checkout` service so you create a new backend service in Cloud Service Mesh. This backend service attaches to the `payment` service using Service Directory for service discovery.\n\nIn this model, the service producer might want to delete or modify the `payment`service that is hosted in Service Directory. Because they own\nthe `payment` service, they are permitted to make such changes. But if the\n`payment` service is deleted, service discovery is broken.\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/v1.24/docs/overview).\n\nLogging\n-------\n\nWhen Cloud Service Mesh resolves a backend service that is attached to a\nService Directory service, it gets a list of endpoints from\nService Directory. If the service has been deleted from\nService Directory, Cloud Service Mesh doesn't get any endpoints.\nIn such a case, a log entry is added to Logging. The log entry\nincludes the following information:\n\n- The backend service name\n- The Service Directory name\n- A message: `Service Directory returned 0 endpoints for this service.`\n\nThis information helps you debug issues. You can also set up alerts to be\nproactively notified.\n\nMonitoring\n----------\n\nSimilar to the logging case, Cloud Service Mesh integrates with\nMonitoring to generate metrics. Cloud Service Mesh adds the\nfollowing metrics to Monitoring for each backend service:\n\n- The backend service name\n- The number of endpoints associated with this backend service that are shared with Cloud Service Mesh's clients\n\nCloud Service Mesh clients are not able to send traffic to backend services that\ndon't have endpoints.\n\nGoogle Cloud console\n--------------------\n\nIf a Service Directory service is deleted and an attachment to\nthat service exists in the Cloud Service Mesh backend service, the\nGoogle Cloud console displays a warning: `The attached\nService Directory service could not be found.`\n\nWhat's next\n-----------\n\n- Learn about [integrating Cloud Service Mesh with Service Directory](/service-mesh/v1.24/docs/service-routing/service-directory-integration).\n- Learn how to [set up the integration](/service-mesh/v1.24/docs/service-routing/service-directory-integration-setup).\n- Learn about [Service Directory observability](/service-directory/docs/monitoring)."]]