可观察性和成本控制
本页介绍监控您的线束、控制执行成本和管理资源标签。
可观测性
每次线束调用都会通过中的 Observ AgentCore ability 自动生成跟踪、日志和指标。 CloudWatch模型调用、工具调用、内存操作、shell 命令:每个步骤都显示时序和有效载荷详细信息。没有额外的配置。跟踪从第一次调用起就可用。
例
- AWS CLI/boto3
-
跟踪、日志和指标 CloudWatch 通过线束执行角色流向。在AgentCore 可观测性控制面板中查看它们,或者通过 CloudWatch 日志和 X-Ray API 以编程方式进行查询。
在查看跟踪之前,请在中启用 “交易搜索” CloudWatch(每个账户一次)。有关设置的详细信息,请参阅AgentCore 可观察性入门。
- AgentCore CLI
-
# Stream logs
agentcore logs --harness research-agent
# Filter
agentcore logs --harness research-agent --since 1h --level error
# List recent traces
agentcore traces list --harness research-agent
# Get a specific trace
agentcore traces get <trace-id> --harness research-agent
了解更多:可观测性概述·指标·遥测
CloudTrail
Harness 操作被记录 AWS CloudTrail 为管理事件(控制平面)和数据事件(数据平面)。在中 CloudTrail,线束资源显示在AWS::BedrockAgentCore::Runtime资源类型下,而不是特定于安全带的类型下。Harness 是 AgentCore 运行时的托管抽象,为了保持一致性, CloudTrail 事件反映了底层的运行时资源。
所有安全带 CloudTrail 事件都使用 resources.type = AWS::BedrockAgentCore::Runtime。事件名称是:
数据平面操作显示为InvokeAgentRuntime和InvokeAgentRuntimeCommand中 CloudTrail,与底层运行时 API 相匹配。该resources.ARN字段包含控制平面事件的线束 ARN 和数据平面事件的运行时 ARN。
通过限制控制成本
设置硬上限,这样失控的特工就不会消耗资源:
-
maxIterations-每次调用 reasoning/action 周期。默认值 75。
-
timeoutSeconds-单次调用的挂钟超时。默认 3600。
-
maxTokens-每次调用的代币预算。默认 N/A。
-
idleRuntimeSessionTimeout-闲置的 microVM 会保温多长时间。默认 900。
-
maxLifetime-microVM 会话的最长生命周期。默认 28800。
所有限制都是可选的;省略这些限制以使用服务默认值。由于线束由 AgentCore Runtime 支持,因此线束调用也受运行时服务配额的约束。有关更多信息,请参阅AgentCore 利用服务配额和AgentCore 运行时服务配额。
例
- AWS CLI/boto3
-
aws bedrock-agentcore-control update-harness \
--harness-id "MyHarness-UuFdkQoXSL" \
--max-iterations 50 \
--timeout-seconds 1800 \
--max-tokens 8192
或者通过传递maxIterations、或 in 来覆盖单timeoutSeconds次调用maxTokens。invoke_harness
- AgentCore CLI
-
设置默认值:
agentcore add harness --name bounded-agent \
--max-iterations 50 --timeout 1800 --max-tokens 8192 \
--truncation-strategy sliding_window \
--idle-timeout 600 --max-lifetime 14400
agentcore deploy
该--truncation-strategy标志接受sliding_window或summarization。--idle-timeout和--max-lifetime标志以秒为单位设置生命周期限制。
在单个呼叫时覆盖:
agentcore invoke --harness bounded-agent --max-iterations 20 --harness-timeout 600 \
"Quick lookup: what's the weather in Seattle?"
将标签应用于您的安全带以进行成本分配和访问控制。
例
- AWS CLI/boto3
-
aws bedrock-agentcore-control create-harness \
--harness-name "MyHarness" \
--execution-role-arn "arn:aws:iam::123456789012:role/MyHarnessRole" \
--tags '{"team": "platform", "environment": "staging"}'
- AgentCore CLI
-
在harness.json以下位置设置标签:
{
"tags": {
"team": "platform",
"environment": "staging"
}
}
跑agentcore deploy去申请。
标签流向已部署的 CloudFormation 资源。