

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 查看跟踪
<a name="trace-view"></a>

下面介绍了如何查看跟踪。选择与您的首选方法对应的选项卡，然后按照以下步骤操作：

------
#### [ Console ]

**在与代理对话期间查看跟踪**

采用有权使用 Amazon Bedrock 控制台的 IAM 身份登录 AWS 管理控制台。然后，通过以下网址打开 Amazon Bedrock 控制台：[https://console.aws.amazon.com/bedrock](https://console.aws.amazon.com/bedrock)。

1. 在**代理**部分，从代理列表中选择要测试的代理的链接。

1. **测试**窗口将显示在右侧的窗格中。

1. 输入一条消息，然后选择**运行**。在生成响应时或完成生成响应后，选择**显示跟踪**。

1. 当代理执行编排时，您可以实时查看每个**步骤**的跟踪。

------
#### [ API ]

要查看跟踪，请使用 [Amazon Bedrock 代理运行时端点](https://docs.aws.amazon.com/general/latest/gr/bedrock.html#bra-rt)发送 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) 请求，并将 `enableTrace` 字段设置为 `TRUE`。默认情况下禁用跟踪。有关示例代码，请参阅[从您的应用程序调用代理](agents-invoke-agent.md)。

如果您启用跟踪，则在 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_InvokeAgent.html) 响应中，流中的每个 `chunk` 都附带一个映射到 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html) 对象的 `trace` 字段。[https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_TracePart.html) 中是一个映射到 [https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Trace.html](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_agent-runtime_Trace.html) 对象的 `trace` 字段。

------