[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C495P3KKK1WAHKM3PBTR6A":3,"skill-same:01M6C495P3KKK1WAHKM3PBTR6A":74},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":18,"categories":19,"keywords":30,"publishedAt":45,"linkOnly":46,"markdownContent":47,"markdownBody":48,"frontMatter":49,"refName":50,"commitSha":51,"skillDirectory":52,"forksCount":53,"repositoryHtmlUrl":54,"repositoryHomepageUrl":55,"ownerHtmlUrl":56,"ownerBlogUrl":57,"ownerDescription":58,"updatedAt":59,"install":60,"resources":73},"01M6C495P3KKK1WAHKM3PBTR6A","check-cloudwatch-session-logs","CloudWatch 会话日志分析","Query and analyze AWS CloudWatch logs\u002Ftraces for Bedrock AgentCore runtime sessions. Use when the user asks about a specific AgentCore session — why it failed, why it hung, what tools it called, how long each step took, or wants to pull the full trace for a given session_id.","查询并分析 Bedrock AgentCore 运行时会话的 AWS CloudWatch 日志\u002F追踪。当用户询问某个特定 AgentCore 会话时使用——例如它为何失败、为何挂起、调用了哪些工具、每个步骤耗时多久，或希望获取给定 session_id 的完整追踪记录。","awslabs\u002Fagentcore-rl-toolkit","awslabs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F3299148?v=4","01M6C492Y04993BB819PCDFE00","Amazon Web Services - Labs","01M6C4931Y4NTEF99J70Y6DXXR",120,"Apache-2.0",null,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-rl-toolkit\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcheck-cloudwatch-session-logs\u002FSKILL.md",[20,25],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BQGD3B3T8FK02S5JVCZA1M","运维监控与告警","SCENARIO","使用场景",{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BQGD4WETX0HM3SM9QKQ15B","SRE 工程师","PROFESSION","适用职业",[31,32,33,34,35,36,37,38,39,40,41,42,43,44],"logs","check","session","check cloudwatch session logs","sessions","pull","aws","Tools","how","why","analyze","trace","user","use","2026-11-10 10:12:30",false,"---\nname: check-cloudwatch-session-logs\ndescription: Query and analyze AWS CloudWatch logs\u002Ftraces for Bedrock AgentCore runtime sessions. Use when the user asks about a specific AgentCore session — why it failed, why it hung, what tools it called, how long each step took, or wants to pull the full trace for a given session_id.\n---\n\nUse this when the user asks about a specific AgentCore session — why it failed, why it hung, what tools it called, how long each step took, or wants to pull the full trace for a given `session_id`.\n\n## Prerequisites\n\n- `aws` CLI configured with credentials for the account hosting the AgentCore runtime (check `aws sts get-caller-identity`).\n- The runtime ARN. Form: `arn:aws:bedrock-agentcore:{region}:{account}:runtime\u002F{name}-{id}` (example: `arn:aws:bedrock-agentcore:us-west-2:000000000000:runtime\u002Fmy_agent-AAAAAAAAAA`). Ask the user for the ARN if they haven't provided one.\n- A session ID (36-char UUID). Ask the user if they haven't provided one — they typically have it from their client-side invocation.\n\n## Two data sources\n\nAgentCore splits telemetry across two CloudWatch log groups:\n\n1. **Runtime logs** — app-level INFO\u002FERROR from the container. Coarse but has session start\u002Fend and top-level errors.\n   - Log group: `\u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F{runtime_name}-{runtime_id}-{qualifier}` (see \"Resolving the log group name from the ARN\" below for picking the qualifier)\n   - Each event is a JSON line with `sessionId`, `level`, `message`, `logger`, `requestId`.\n\n2. **Spans (`aws\u002Fspans`)** — OpenTelemetry traces. Fine-grained: every tool call, every model call, every S3 op, every downstream API call.\n   - Log group: `aws\u002Fspans` (shared across all runtimes in the region)\n   - Filter by `attributes.session.id = \"\u003Csid>\"` to scope to one session.\n   - Each event has `name`, `kind`, `durationNano`, `attributes.gen_ai.operation.name`, `attributes.tool.name`, plus any exceptions in `events[]`.\n\nUse source (1) for \"did the session start \u002F end \u002F error at the app level?\". Use source (2) for \"what did the agent actually do?\".\n\n## Resolving the log group name from the ARN\n\nGiven `arn:aws:bedrock-agentcore:{region}:{account}:runtime\u002F{name}-{id}` (e.g., `arn:aws:bedrock-agentcore:us-west-2:000000000000:runtime\u002Fmy_agent-AAAAAAAAAA`):\n\n- `alias = {name}-{id}` — the part after `runtime\u002F` (e.g., `my_agent-AAAAAAAAAA`)\n- Region = 4th `:`-separated field of the ARN (e.g., `us-west-2`)\n- Runtime log group = `\u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F{alias}-{qualifier}`\n\nThe `{qualifier}` is the **endpoint name**. `DEFAULT` is what `invoke_agent_runtime(...)` routes to when called without a `qualifier=` argument (see [InvokeAgentRuntime API](https:\u002F\u002Fdocs.aws.amazon.com\u002Fbedrock-agentcore\u002Flatest\u002FAPIReference\u002FAPI_InvokeAgentRuntime.html)), but custom endpoints created via `CreateAgentRuntimeEndpoint` use a different name.\n\nBefore assuming `DEFAULT`, list which qualifiers actually have logs:\n\n```bash\naws logs describe-log-groups --region $REGION \\\n  --log-group-name-prefix \u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F${ALIAS}- \\\n  --query 'logGroups[].logGroupName' --output text\n```\n\n- **One result ending in `-DEFAULT`** → use it.\n- **Multiple results** → ask the user which endpoint they invoked (the suffix after the last `-` is the qualifier).\n- **No results** → the runtime hasn't been invoked yet, or it was invoked under a qualifier whose log group was never created. Ask the user to confirm the ARN and qualifier, since log groups are only created lazily on first traffic to that endpoint.\n\n## Recipes\n\n> **Note:** `REGION` and `ALIAS` come from the runtime ARN — `REGION` is the 4th `:`-separated field, `ALIAS` is the part after `runtime\u002F`. Set them once before running the recipes below.\n\n### 1. List recent sessions (to find a session_id)\n\n```bash\nREGION=us-west-2\nALIAS=my_agent-AAAAAAAAAA\nQUALIFIER=DEFAULT  # the endpoint name; verify via describe-log-groups above\nLG=\u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F${ALIAS}-${QUALIFIER}\nWINDOW=1800  # seconds\n\nQID=$(aws logs start-query --region $REGION --log-group-name \"$LG\" \\\n  --start-time $(($(date +%s) - $WINDOW)) --end-time $(date +%s) \\\n  --query-string 'stats count(*) as events, earliest(@timestamp) as start, latest(@timestamp) as last by sessionId | sort last desc | limit 20' \\\n  --query 'queryId' --output text)\n\n# Poll until Complete — busy regions can take >10s\nwhile [[ \"$(aws logs get-query-results --region $REGION --query-id $QID --query 'status' --output text)\" != \"Complete\" ]]; do\n  sleep 2\ndone\naws logs get-query-results --region $REGION --query-id $QID --output json\n```\n\n### 2. Runtime-log events for one session (app-level story)\n\n```bash\nSID=00000000-0000-0000-0000-000000000000  # replace with the real session UUID\n# REGION, ALIAS, QUALIFIER, LG as in recipe 1\n\naws logs filter-log-events --region $REGION --log-group-name \"$LG\" \\\n  --filter-pattern \"{ \\$.sessionId = \\\"$SID\\\" }\" \\\n  --start-time $(($(date +%s) - 3600))000 \\\n  --query 'events[].message' --output text\n```\n\n`filter-log-events` takes **epoch-milliseconds** (note trailing `000`). `start-query` takes epoch-seconds.\n\n`--output text` joins all events with tabs onto one line — pipe through `tr '\\t' '\\n'` to read line-by-line.\n\n### 3. Full OTel span timeline for a session\n\n`aws\u002Fspans` is a regional log group that holds traces from every runtime in the account, so it's huge. Narrow the time window to the session's actual lifetime — recipe 2's first event timestamp is a good lower bound. (Sized this way, scans drop to roughly half versus a 24h sweep.) `aws\u002Fspans` doesn't index session.id efficiently, so window size dominates query cost.\n\n```bash\nSID=00000000-0000-0000-0000-000000000000  # replace with the real session UUID\n# REGION, LG as in recipe 1\n\n# Use recipe 2's earliest event as the start; pad 60s before for safety.\nSTART_MS=$(aws logs filter-log-events --region $REGION --log-group-name \"$LG\" \\\n  --filter-pattern \"{ \\$.sessionId = \\\"$SID\\\" }\" \\\n  --start-time $(($(date +%s) - 86400))000 \\\n  --output json | jq '[.events[].timestamp] | min')\nSPANS_START=$(( START_MS \u002F 1000 - 60 ))\n\nQID=$(aws logs start-query --region $REGION --log-group-name aws\u002Fspans \\\n  --start-time $SPANS_START --end-time $(date +%s) \\\n  --query-string \"filter attributes.session.id = \\\"$SID\\\" | fields @timestamp, name, kind, attributes.gen_ai.operation.name, attributes.tool.name, durationNano, status.code | sort @timestamp asc | limit 500\" \\\n  --query 'queryId' --output text)\n\nwhile [[ \"$(aws logs get-query-results --region $REGION --query-id $QID --query 'status' --output text)\" != \"Complete\" ]]; do\n  sleep 2\ndone\naws logs get-query-results --region $REGION --query-id $QID --output json\n```\n\nTypical output shape — alternating model calls and tool calls:\n\n```\n[t+0]    POST \u002Finvocations              (entry)\n[t+0.1]  S3.GetObject                   (repo fetch)\n[t+30]   chat                           op=chat           (model call)\n[t+30.5] execute_tool shell             op=execute_tool   (tool exec)\n[t+31]   execute_event_loop_cycle       (strands loop)\n...\n```\n\n### 4. Pull exceptions across all spans\n\n```bash\nQID=$(aws logs start-query --region us-west-2 --log-group-name aws\u002Fspans \\\n  --start-time $(($(date +%s) - 3600)) --end-time $(date +%s) \\\n  --query-string 'filter status.code = \"ERROR\" | fields @timestamp, name, attributes.session.id, status.message | sort @timestamp desc | limit 50' \\\n  --query 'queryId' --output text)\n\nwhile [[ \"$(aws logs get-query-results --region us-west-2 --query-id $QID --query 'status' --output text)\" != \"Complete\" ]]; do\n  sleep 2\ndone\naws logs get-query-results --region us-west-2 --query-id $QID --output json\n```\n\n## Analysis patterns\n\nWhen inspecting, answer these in order:\n\n1. **Did it start?** First event should be `POST \u002Finvocations`. If missing, the runtime never received the request (check agent ARN, network, IAM).\n2. **Did the agent call the model?** Look for `chat` spans with `gen_ai.operation.name=chat`. If none, the model never responded — likely chat-template\u002Ftool-parser mismatch (returns empty `end_turn`).\n3. **Did tools execute?** `execute_tool` spans. Successive tool calls with growing `durationNano` typically mean the agent is building\u002Ftesting (Maven, npm, tests). Single tool call with no follow-up = agent gave up or errored.\n4. **Did it finish cleanly?** Last runtime log event should be `Async task completed: invoke_agent`. If not, the session is either still running or was killed by `session_timeout`.\n5. **Any exceptions?** Check `events[].name==\"exception\"` inside spans. `status.code=ERROR` surfaces these in the top-level fields.\n\n## Constructing the CloudWatch console URL\n\nIf the user wants to click through to the UI:\n\n```python\nfrom urllib.parse import quote\n\ndef cloudwatch_session_url(arn: str, session_id: str, qualifier: str = \"DEFAULT\") -> str:\n    region = arn.split(\":\")[3]\n    alias = arn.split(\"\u002F\")[-1]                    # e.g., my_agent-AAAAAAAAAA\n    name = alias.rsplit(\"-\", 1)[0]                # e.g., my_agent\n    resource_id = quote(f\"{arn}\u002Fruntime-endpoint\u002F{qualifier}:{qualifier}\", safe=\"\")\n    return (\n        f\"https:\u002F\u002F{region}.console.aws.amazon.com\u002Fcloudwatch\u002Fhome?region={region}\"\n        f\"#gen-ai-observability\u002Fagent-core\"\n        f\"\u002Fagent-alias\u002F{alias}\u002Fendpoint\u002F{qualifier}\u002Fagent\u002F{name}\u002Fsession\u002F{session_id}\"\n        f\"?resourceId={resource_id}&serviceName={name}.{qualifier}\"\n    )\n```\n\n## When a query returns zero events\n\nIf recipe 2 or 3 returns nothing for a session you're sure ran, work through these in order before assuming the session never executed:\n\n1. **Wrong qualifier?** Re-run `aws logs describe-log-groups --log-group-name-prefix \u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F${ALIAS}-` and confirm the suffix matches the qualifier the client invoked with. `DEFAULT` is only correct when no `qualifier=` was passed.\n2. **Wrong region?** The ARN's 4th `:`-field is the runtime region; the AWS CLI default region (or `AWS_REGION`) must match it.\n3. **Stale time window?** `filter-log-events --start-time` and `start-query --start-time` both default to \"recent.\" Older sessions need a larger window — the runtime ARN's `creationTime` from `describe-log-groups` is a hard lower bound.\n4. **Typo'd or wrongly-cased session_id?** AgentCore session IDs are case-sensitive lowercased UUIDs. Copy from the source rather than retyping.\n5. **Session never reached the runtime?** If recipe 2 returns no events even with a wide window, the runtime never received the request — check the client-side `invoke_agent_runtime` response, network\u002FIAM, and the agent ARN itself. Recipe 1 (\"list recent sessions\") confirms whether *any* sessions are landing.\n\n## Gotchas\n\n- **`filter-log-events` does NOT accept `@timestamp` in its filter pattern.** Use `start-time`\u002F`end-time` args (epoch-ms) instead.\n- **`attributes.session.id` (with dots)** — CloudWatch Logs Insights requires backtick-quoting only for keys with dashes, hyphens, or reserved words. Plain dots work unquoted.\n- **Runtime logs vs spans differ in completeness.** A session that returned fast with no model call will have ~3 runtime-log events but zero spans (no instrumented work happened). Conversely, a session that crashed mid-stream may have 100+ spans but only a single \"task started\" runtime log — useful for debugging in-flight failures.\n- **Session ID must be lowercased UUID.** AgentCore treats them case-sensitively.\n- **Spans don't always arrive in order.** Use `sort @timestamp asc` explicitly.\n","Use this when the user asks about a specific AgentCore session — why it failed, why it hung, what tools it called, how long each step took, or wants to pull the full trace for a given `session_id`.\n\n## Prerequisites\n\n- `aws` CLI configured with credentials for the account hosting the AgentCore runtime (check `aws sts get-caller-identity`).\n- The runtime ARN. Form: `arn:aws:bedrock-agentcore:{region}:{account}:runtime\u002F{name}-{id}` (example: `arn:aws:bedrock-agentcore:us-west-2:000000000000:runtime\u002Fmy_agent-AAAAAAAAAA`). Ask the user for the ARN if they haven't provided one.\n- A session ID (36-char UUID). Ask the user if they haven't provided one — they typically have it from their client-side invocation.\n\n## Two data sources\n\nAgentCore splits telemetry across two CloudWatch log groups:\n\n1. **Runtime logs** — app-level INFO\u002FERROR from the container. Coarse but has session start\u002Fend and top-level errors.\n   - Log group: `\u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F{runtime_name}-{runtime_id}-{qualifier}` (see \"Resolving the log group name from the ARN\" below for picking the qualifier)\n   - Each event is a JSON line with `sessionId`, `level`, `message`, `logger`, `requestId`.\n\n2. **Spans (`aws\u002Fspans`)** — OpenTelemetry traces. Fine-grained: every tool call, every model call, every S3 op, every downstream API call.\n   - Log group: `aws\u002Fspans` (shared across all runtimes in the region)\n   - Filter by `attributes.session.id = \"\u003Csid>\"` to scope to one session.\n   - Each event has `name`, `kind`, `durationNano`, `attributes.gen_ai.operation.name`, `attributes.tool.name`, plus any exceptions in `events[]`.\n\nUse source (1) for \"did the session start \u002F end \u002F error at the app level?\". Use source (2) for \"what did the agent actually do?\".\n\n## Resolving the log group name from the ARN\n\nGiven `arn:aws:bedrock-agentcore:{region}:{account}:runtime\u002F{name}-{id}` (e.g., `arn:aws:bedrock-agentcore:us-west-2:000000000000:runtime\u002Fmy_agent-AAAAAAAAAA`):\n\n- `alias = {name}-{id}` — the part after `runtime\u002F` (e.g., `my_agent-AAAAAAAAAA`)\n- Region = 4th `:`-separated field of the ARN (e.g., `us-west-2`)\n- Runtime log group = `\u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F{alias}-{qualifier}`\n\nThe `{qualifier}` is the **endpoint name**. `DEFAULT` is what `invoke_agent_runtime(...)` routes to when called without a `qualifier=` argument (see [InvokeAgentRuntime API](https:\u002F\u002Fdocs.aws.amazon.com\u002Fbedrock-agentcore\u002Flatest\u002FAPIReference\u002FAPI_InvokeAgentRuntime.html)), but custom endpoints created via `CreateAgentRuntimeEndpoint` use a different name.\n\nBefore assuming `DEFAULT`, list which qualifiers actually have logs:\n\n```bash\naws logs describe-log-groups --region $REGION \\\n  --log-group-name-prefix \u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F${ALIAS}- \\\n  --query 'logGroups[].logGroupName' --output text\n```\n\n- **One result ending in `-DEFAULT`** → use it.\n- **Multiple results** → ask the user which endpoint they invoked (the suffix after the last `-` is the qualifier).\n- **No results** → the runtime hasn't been invoked yet, or it was invoked under a qualifier whose log group was never created. Ask the user to confirm the ARN and qualifier, since log groups are only created lazily on first traffic to that endpoint.\n\n## Recipes\n\n> **Note:** `REGION` and `ALIAS` come from the runtime ARN — `REGION` is the 4th `:`-separated field, `ALIAS` is the part after `runtime\u002F`. Set them once before running the recipes below.\n\n### 1. List recent sessions (to find a session_id)\n\n```bash\nREGION=us-west-2\nALIAS=my_agent-AAAAAAAAAA\nQUALIFIER=DEFAULT  # the endpoint name; verify via describe-log-groups above\nLG=\u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F${ALIAS}-${QUALIFIER}\nWINDOW=1800  # seconds\n\nQID=$(aws logs start-query --region $REGION --log-group-name \"$LG\" \\\n  --start-time $(($(date +%s) - $WINDOW)) --end-time $(date +%s) \\\n  --query-string 'stats count(*) as events, earliest(@timestamp) as start, latest(@timestamp) as last by sessionId | sort last desc | limit 20' \\\n  --query 'queryId' --output text)\n\n# Poll until Complete — busy regions can take >10s\nwhile [[ \"$(aws logs get-query-results --region $REGION --query-id $QID --query 'status' --output text)\" != \"Complete\" ]]; do\n  sleep 2\ndone\naws logs get-query-results --region $REGION --query-id $QID --output json\n```\n\n### 2. Runtime-log events for one session (app-level story)\n\n```bash\nSID=00000000-0000-0000-0000-000000000000  # replace with the real session UUID\n# REGION, ALIAS, QUALIFIER, LG as in recipe 1\n\naws logs filter-log-events --region $REGION --log-group-name \"$LG\" \\\n  --filter-pattern \"{ \\$.sessionId = \\\"$SID\\\" }\" \\\n  --start-time $(($(date +%s) - 3600))000 \\\n  --query 'events[].message' --output text\n```\n\n`filter-log-events` takes **epoch-milliseconds** (note trailing `000`). `start-query` takes epoch-seconds.\n\n`--output text` joins all events with tabs onto one line — pipe through `tr '\\t' '\\n'` to read line-by-line.\n\n### 3. Full OTel span timeline for a session\n\n`aws\u002Fspans` is a regional log group that holds traces from every runtime in the account, so it's huge. Narrow the time window to the session's actual lifetime — recipe 2's first event timestamp is a good lower bound. (Sized this way, scans drop to roughly half versus a 24h sweep.) `aws\u002Fspans` doesn't index session.id efficiently, so window size dominates query cost.\n\n```bash\nSID=00000000-0000-0000-0000-000000000000  # replace with the real session UUID\n# REGION, LG as in recipe 1\n\n# Use recipe 2's earliest event as the start; pad 60s before for safety.\nSTART_MS=$(aws logs filter-log-events --region $REGION --log-group-name \"$LG\" \\\n  --filter-pattern \"{ \\$.sessionId = \\\"$SID\\\" }\" \\\n  --start-time $(($(date +%s) - 86400))000 \\\n  --output json | jq '[.events[].timestamp] | min')\nSPANS_START=$(( START_MS \u002F 1000 - 60 ))\n\nQID=$(aws logs start-query --region $REGION --log-group-name aws\u002Fspans \\\n  --start-time $SPANS_START --end-time $(date +%s) \\\n  --query-string \"filter attributes.session.id = \\\"$SID\\\" | fields @timestamp, name, kind, attributes.gen_ai.operation.name, attributes.tool.name, durationNano, status.code | sort @timestamp asc | limit 500\" \\\n  --query 'queryId' --output text)\n\nwhile [[ \"$(aws logs get-query-results --region $REGION --query-id $QID --query 'status' --output text)\" != \"Complete\" ]]; do\n  sleep 2\ndone\naws logs get-query-results --region $REGION --query-id $QID --output json\n```\n\nTypical output shape — alternating model calls and tool calls:\n\n```\n[t+0]    POST \u002Finvocations              (entry)\n[t+0.1]  S3.GetObject                   (repo fetch)\n[t+30]   chat                           op=chat           (model call)\n[t+30.5] execute_tool shell             op=execute_tool   (tool exec)\n[t+31]   execute_event_loop_cycle       (strands loop)\n...\n```\n\n### 4. Pull exceptions across all spans\n\n```bash\nQID=$(aws logs start-query --region us-west-2 --log-group-name aws\u002Fspans \\\n  --start-time $(($(date +%s) - 3600)) --end-time $(date +%s) \\\n  --query-string 'filter status.code = \"ERROR\" | fields @timestamp, name, attributes.session.id, status.message | sort @timestamp desc | limit 50' \\\n  --query 'queryId' --output text)\n\nwhile [[ \"$(aws logs get-query-results --region us-west-2 --query-id $QID --query 'status' --output text)\" != \"Complete\" ]]; do\n  sleep 2\ndone\naws logs get-query-results --region us-west-2 --query-id $QID --output json\n```\n\n## Analysis patterns\n\nWhen inspecting, answer these in order:\n\n1. **Did it start?** First event should be `POST \u002Finvocations`. If missing, the runtime never received the request (check agent ARN, network, IAM).\n2. **Did the agent call the model?** Look for `chat` spans with `gen_ai.operation.name=chat`. If none, the model never responded — likely chat-template\u002Ftool-parser mismatch (returns empty `end_turn`).\n3. **Did tools execute?** `execute_tool` spans. Successive tool calls with growing `durationNano` typically mean the agent is building\u002Ftesting (Maven, npm, tests). Single tool call with no follow-up = agent gave up or errored.\n4. **Did it finish cleanly?** Last runtime log event should be `Async task completed: invoke_agent`. If not, the session is either still running or was killed by `session_timeout`.\n5. **Any exceptions?** Check `events[].name==\"exception\"` inside spans. `status.code=ERROR` surfaces these in the top-level fields.\n\n## Constructing the CloudWatch console URL\n\nIf the user wants to click through to the UI:\n\n```python\nfrom urllib.parse import quote\n\ndef cloudwatch_session_url(arn: str, session_id: str, qualifier: str = \"DEFAULT\") -> str:\n    region = arn.split(\":\")[3]\n    alias = arn.split(\"\u002F\")[-1]                    # e.g., my_agent-AAAAAAAAAA\n    name = alias.rsplit(\"-\", 1)[0]                # e.g., my_agent\n    resource_id = quote(f\"{arn}\u002Fruntime-endpoint\u002F{qualifier}:{qualifier}\", safe=\"\")\n    return (\n        f\"https:\u002F\u002F{region}.console.aws.amazon.com\u002Fcloudwatch\u002Fhome?region={region}\"\n        f\"#gen-ai-observability\u002Fagent-core\"\n        f\"\u002Fagent-alias\u002F{alias}\u002Fendpoint\u002F{qualifier}\u002Fagent\u002F{name}\u002Fsession\u002F{session_id}\"\n        f\"?resourceId={resource_id}&serviceName={name}.{qualifier}\"\n    )\n```\n\n## When a query returns zero events\n\nIf recipe 2 or 3 returns nothing for a session you're sure ran, work through these in order before assuming the session never executed:\n\n1. **Wrong qualifier?** Re-run `aws logs describe-log-groups --log-group-name-prefix \u002Faws\u002Fbedrock-agentcore\u002Fruntimes\u002F${ALIAS}-` and confirm the suffix matches the qualifier the client invoked with. `DEFAULT` is only correct when no `qualifier=` was passed.\n2. **Wrong region?** The ARN's 4th `:`-field is the runtime region; the AWS CLI default region (or `AWS_REGION`) must match it.\n3. **Stale time window?** `filter-log-events --start-time` and `start-query --start-time` both default to \"recent.\" Older sessions need a larger window — the runtime ARN's `creationTime` from `describe-log-groups` is a hard lower bound.\n4. **Typo'd or wrongly-cased session_id?** AgentCore session IDs are case-sensitive lowercased UUIDs. Copy from the source rather than retyping.\n5. **Session never reached the runtime?** If recipe 2 returns no events even with a wide window, the runtime never received the request — check the client-side `invoke_agent_runtime` response, network\u002FIAM, and the agent ARN itself. Recipe 1 (\"list recent sessions\") confirms whether *any* sessions are landing.\n\n## Gotchas\n\n- **`filter-log-events` does NOT accept `@timestamp` in its filter pattern.** Use `start-time`\u002F`end-time` args (epoch-ms) instead.\n- **`attributes.session.id` (with dots)** — CloudWatch Logs Insights requires backtick-quoting only for keys with dashes, hyphens, or reserved words. Plain dots work unquoted.\n- **Runtime logs vs spans differ in completeness.** A session that returned fast with no model call will have ~3 runtime-log events but zero spans (no instrumented work happened). Conversely, a session that crashed mid-stream may have 100+ spans but only a single \"task started\" runtime log — useful for debugging in-flight failures.\n- **Session ID must be lowercased UUID.** AgentCore treats them case-sensitively.\n- **Spans don't always arrive in order.** Use `sort @timestamp asc` explicitly.\n",{"name":5,"description":7},"main","55d173c93915a0e0fb445130c86555c4fb3d54e8",".agents\u002Fskills\u002Fcheck-cloudwatch-session-logs",22,"https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-rl-toolkit","https:\u002F\u002Fawslabs.github.io\u002Fagentcore-rl-toolkit\u002F","https:\u002F\u002Fgithub.com\u002Fawslabs","http:\u002F\u002Famazon.com\u002Faws\u002F","AWS Labs","2026-11-14 09:06:20",{"source":9,"skillName":5,"commands":61,"prompt":71,"zipAvailable":72},[62,65,68],{"tool":63,"command":64},"npx","npx skills add awslabs\u002Fagentcore-rl-toolkit --skill check-cloudwatch-session-logs",{"tool":66,"command":67},"bunx","bunx skills add awslabs\u002Fagentcore-rl-toolkit --skill check-cloudwatch-session-logs",{"tool":69,"command":70},"pnpm","pnpm dlx skills add awslabs\u002Fagentcore-rl-toolkit --skill check-cloudwatch-session-logs","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-rl-toolkit\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fcheck-cloudwatch-session-logs\u002FSKILL.md",true,[],[75,92,99],{"skillNo":76,"name":77,"nameZh":78,"description":17,"descriptionZh":79,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":80,"categories":81,"keywords":88,"publishedAt":45},"01M6C49CP1P2XJJW8NZYAQ05FD","deploy-and-test-agent","AgentCore 智能体部署与测试","","https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-rl-toolkit\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdeploy-and-test-agent\u002FSKILL.md",[82,85],{"categoryNo":83,"categoryName":84,"taxonomyType":28,"taxonomyTypeDesc":29},"01M8BRZZF9D7PVFN5MXSPWWD61","AI 工程师",{"categoryNo":86,"categoryName":87,"taxonomyType":23,"taxonomyTypeDesc":24},"01M8BSAA4FBTWZP6X98STEHG99","智能体开发",[89,90,91],"deploy and test agent","deploy","test",{"skillNo":93,"name":5,"nameZh":6,"description":17,"descriptionZh":79,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":94,"categories":95,"keywords":98,"publishedAt":45},"01M6C49AZFPTM3FCTG4GDMJGMQ","https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-rl-toolkit\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fcheck-cloudwatch-session-logs\u002FSKILL.md",[96,97],{"categoryNo":21,"categoryName":22,"taxonomyType":23,"taxonomyTypeDesc":24},{"categoryNo":26,"categoryName":27,"taxonomyType":28,"taxonomyTypeDesc":29},[34,33,32,31],{"skillNo":100,"name":77,"nameZh":78,"description":101,"descriptionZh":102,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":17,"sourceHtmlUrl":103,"categories":104,"keywords":107,"publishedAt":45},"01M6C498CMK5M0KNB19DJMQZA8","Deploy repository example agents to Bedrock AgentCore Runtime or validate their changes locally and in the cloud. Use for example deployment and integration tests, including testing unpublished agentcore-rl-toolkit code.","将仓库中的示例智能体部署到 Bedrock AgentCore Runtime，或在本地和云端验证其更改。用于示例部署和集成测试，包括测试尚未发布的 agentcore-rl-toolkit 代码。","https:\u002F\u002Fgithub.com\u002Fawslabs\u002Fagentcore-rl-toolkit\u002Fblob\u002Fmain\u002F.agents\u002Fskills\u002Fdeploy-and-test-agent\u002FSKILL.md",[105,106],{"categoryNo":83,"categoryName":84,"taxonomyType":28,"taxonomyTypeDesc":29},{"categoryNo":86,"categoryName":87,"taxonomyType":23,"taxonomyTypeDesc":24},[91,89,90,108,109,44,110,111,112,113,114,115,116,117,118,119],"repository","cloud","example","agentcore","rl","integration","code","toolkit","deployment","validate","integration tests","testing"]