可觀測性和成本控制
此頁面涵蓋監控您的設備、控制執行成本和管理資源標籤。
可觀測性
每個工具叫用都會透過 CloudWatch 中的 AgentCore 可觀測性自動產生追蹤、日誌和指標。模型呼叫、工具叫用、記憶體操作、 shell 命令:每個步驟都會顯示時間和承載詳細資訊。沒有額外的組態。追蹤可從第一次調用取得。
範例
- AWS CLI/boto3
-
追蹤、日誌和指標會透過繫帶執行角色流向 CloudWatch。在 AgentCore 可觀測性儀表板中檢視它們,或透過 CloudWatch Logs 和 X-Ray APIs 以程式設計方式進行查詢。
在看到追蹤之前,請在 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
繫結操作會記錄為管理事件 (控制平面) 和資料事件 (資料平面) 的 AWS CloudTrail。在 CloudTrail 中,集合資源會出現在AWS::BedrockAgentCore::Runtime資源類型下,而不是集合特定類型。Harness 是 AgentCore 執行期的受管抽象,CloudTrail 事件會反映基礎執行期資源以確保一致性。
所有 CloudTrail 事件都使用 resources.type = AWS::BedrockAgentCore::Runtime。事件名稱為:
資料平面操作在 CloudTrail InvokeAgentRuntimeCommand中顯示為 InvokeAgentRuntime和 ,符合基礎執行期 API。resources.ARN 欄位包含控制平面事件的固定 ARN 和資料平面事件的執行期 ARN。
使用限制控制成本
設定硬蓋,讓失控代理程式無法穿透資源:
-
maxIterations - 每次調用的推理/動作週期。預設 75。
-
timeoutSeconds - 單一調用的牆壁時鐘逾時。預設 3600。
-
maxTokens - 每次呼叫的字符預算。預設不適用。
-
idleRuntimeSessionTimeout - 閒置microVM保持暖機的時間長度。預設 900。
-
maxLifetime - microVM 工作階段的最長存留期。預設 28800。
所有限制都是選用的;請省略它們以使用服務預設值。由於繫帶由 AgentCore Runtime 支援,因此繫帶調用也會受到 Runtime 服務配額的限制。如需詳細資訊,請參閱 AgentCore harness Service Quotas 和 AgentCore Runtime Service Quotas。
範例
- AWS CLI/boto3
-
aws bedrock-agentcore-control update-harness \
--harness-id "MyHarness-UuFdkQoXSL" \
--max-iterations 50 \
--timeout-seconds 1800 \
--max-tokens 8192
或在 maxTokens中傳遞 maxIterations、 timeoutSeconds或 來覆寫單一調用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 資源。