使用 Service Directory 進行監控和偵錯

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.

後續步驟