

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 使用 sourceIdentity 從 SageMaker AI Studio Classic 監控使用者資源存取
<a name="monitor-user-access"></a>

使用 Amazon SageMaker Studio Classic，您就可以監控使用者資源存取。若要檢視資源存取活動，您可以依照 [使用 記錄 Amazon SageMaker API 呼叫 AWS CloudTrail](https://docs.aws.amazon.com/sagemaker/latest/dg/logging-using-cloudtrail.html)中的步驟，設定 AWS CloudTrail 來監控和記錄使用者活動。

不過，資源存取的 AWS CloudTrail 日誌只會列出 Studio Classic 執行 IAM 角色做為識別符。當每個使用者設定檔都有不同的執行角色時，這個記錄層級就足以稽核使用者活動。不過，在多個使用者設定檔之間共用單一執行 IAM 角色時，您無法取得存取 AWS 資源之特定使用者的相關資訊。  

在使用共用執行角色時，您可以使用 `sourceIdentity` 組態傳播 Studio Classic 使用者設定檔名稱，取得哪一名特定使用者在 AWS CloudTrail 日誌中執行動作的資訊。如需來源身分的詳細資訊，請參閱[監控並控制使用擔任角色所採取的動作](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_temp_control-access_monitor.html)。若要開啟或關閉 CloudTrail 日誌的 `sourceIdentity`，請參閱[在 SageMaker AI Studio Classic 的 CloudTrail 日誌中開啟 sourceIdentity](monitor-user-access-how-to.md)。

## sourceIdentity 使用考量事項
<a name="monitor-user-access-considerations"></a>

當您從 Studio Classic 筆記本、SageMaker Canvas 或 Amazon SageMaker Data Wrangler 進行 AWS API 呼叫時，只有在使用 Studio Classic [執行角色](sagemaker-roles.md)工作階段或來自該工作階段的任何[鏈結角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-role-chaining)進行這些呼叫時，`sourceIdentity`才會在 CloudTrail 中記錄 。

當這些 API 呼叫調用其他服務執行其他操作時，`sourceIdentity` 記錄取決於調用服務的特定實作。
+ Amazon SageMaker 訓練與處理：使用訓練功能或處理功能建立任務時，任務建立 API 呼叫會擷取存在於工作階段中的 `sourceIdentity`。因此，從這些任務進行的任何 AWS API 呼叫會在 CloudTrail 日誌中記錄 `sourceIdentity`。
+ Amazon SageMaker Pipelines：當您使用自動化 CI/CD 管道建立任務時，`sourceIdentity` 會在下游傳播，並可在 CloudTrail 日誌中檢視。
+ Amazon EMR：使用[執行時期角色](studio-notebooks-emr-cluster-rbac.md)從 Studio Classic 連線至 Amazon EMR 時，系統管理員必須明確[設定 PropagateSourceIdentity 欄位](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-steps-runtime-roles.html)。這可確保 Amazon EMR 會將呼叫憑證的 `sourceIdentity` 套用到任務或查詢工作階段。然後，會在 CloudTrail 日誌中記錄 `sourceIdentity`。

**注意**  
使用 `sourceIdentity` 時，以下例外情況適用。  
SageMaker Studio Classic 共用空間不支援`sourceIdentity`傳遞。從 SageMaker AI 共用空間發出的 AWS API 呼叫不會記錄在 CloudTrail 日誌`sourceIdentity`中。
如果 AWS API 呼叫是從使用者或其他 服務建立的工作階段發出，而且工作階段不是以 Studio Classic 執行角色工作階段為基礎，則 `sourceIdentity` 不會記錄在 CloudTrail 日誌中。