您可以使用 Identity and Access Management (IAM) 角色,授予檢視、寫入或管理 Cloud Trace 資源的精細權限,並防止未經授權存取追蹤記錄資料。
- 如要瞭解如何將 IAM 角色授予使用者或服務帳戶,請參閱「管理專案、資料夾和機構的存取權」。
- 如需預先定義角色的相關資訊,請參閱「IAM:角色和權限」。
- 如需選擇最合適預先定義角色的說明,請參閱「選擇預先定義的角色」。
最佳做法
為方便進行疑難排解,請為需要查看專案中追蹤資料的所有人員、群組和網域,授予 Cloud Trace 使用者角色 (roles/cloudtrace.user)。這個角色會授予主體查看追蹤資料所需的權限。
權限和預先定義的角色
身分與存取權管理角色包含權限,可以指派給使用者、群組和服務帳戶。
Cloud Trace 角色
下表列出 Cloud Trace 的預先定義角色,以及這些角色的權限:
| Role | Permissions |
|---|---|
Cloud Trace Admin( Provides full access to the Trace console and read-write access to traces. Lowest-level resources where you can grant this role:
|
|
Cloud Trace User( Provides full access to the Trace console and read access to traces. Lowest-level resources where you can grant this role:
|
|
Cloud Trace Agent( For service accounts. Provides ability to write traces by sending the data to Stackdriver Trace. Lowest-level resources where you can grant this role:
|
|
Telemetry API 角色
下表列出 Telemetry (OTLP) API 的預先定義角色,以及這些角色的權限:
| Role | Permissions |
|---|---|
Telemetry Admin( Admin role for telemetry |
|
Telemetry Editor( Editor role for telemetry |
|
Consumer Admin Beta( Grants permission management access to consumer resources. |
|
Cloud Telemetry Logs Writer( Access to write logs. |
|
Cloud Telemetry Metrics Writer( Access to write metrics. |
|
Integrated Service Telemetry Logs Writer Beta( Allows an onboarded service to write log data to a destination. |
|
Integrated Service Telemetry Metrics Writer Beta( Allows an onboarded service to write metrics data to a destination. |
|
Integrated Service Telemetry Writer Beta( Allows an onboarded service to write all telemetry data to a destination. |
|
Integrated Service Telemetry Traces Writer Beta( Allows an onboarded service to write trace data to a destination. |
|
Cloud Telemetry Traces Writer( Access to write trace spans. |
|
Cloud Telemetry Writer( Full access to write all telemetry data. |
|
建立自訂角色
如要建立擁有 Cloud Trace 權限的自訂角色,請執行下列步驟:
- 如要建立僅含 Cloud Trace API 使用權限的角色,請選取 API 呼叫所需的特定權限。
- 如要建立含有 Cloud Trace API 和Google Cloud 主控台使用權限的角色,請從預先定義的 Cloud Trace 角色中選擇權限群組。
- 如要授予寫入追蹤記錄資料的權限,請從 Cloud Trace 代理程式角色 (
roles/cloudtrace.agent) 複製權限。
如要進一步瞭解自訂角色,請參閱「建立及管理自訂角色」一文。
API 方法的權限
如要瞭解執行 API 呼叫所需的權限,請參閱 Cloud Trace API 參考文件:
跨專案追蹤的角色
您的應用程式可能會將追蹤記錄資料儲存在多個 Google Cloud 專案中。 不過,只要執行下列操作,您就能在單一專案中查看這項資料:
在要查看追蹤記錄資料的專案中,設定追蹤記錄範圍。如要設定這個範圍,您必須具備觀測範圍編輯者角色 (
roles/observability.scopesEditor)。在要查看追蹤記錄資料的專案,以及儲存追蹤記錄資料的所有專案中,您都擁有 Cloud Trace 使用者角色 (
roles/cloudtrace.user)。
詳情請參閱「查看跨專案的追蹤記錄」。