feat: add logs command for streaming and searching agent runtime logs#486
Open
jesseturner21 wants to merge 2 commits intomainfrom
Open
feat: add logs command for streaming and searching agent runtime logs#486jesseturner21 wants to merge 2 commits intomainfrom
logs command for streaming and searching agent runtime logs#486jesseturner21 wants to merge 2 commits intomainfrom
Conversation
Add a new `agentcore logs` command that provides real-time streaming and historical search of agent runtime logs via CloudWatch Logs. - Stream mode (default): Uses StartLiveTail for real-time log streaming with auto-reconnect on 3-hour session timeout - Search mode (--since/--until): Uses FilterLogEvents with pagination for bounded time-range queries - Server-side filtering via --level (error/warn/info/debug) and --query - JSON Lines output with --json flag - Agent resolution from project config + deployed state - Time parser supporting relative durations (5m, 1h, 2d), ISO 8601, epoch ms, and "now" - Fix .gitignore to scope `logs` pattern to top-level only
Contributor
Coverage Report
|
- Remove unused `logStreamName` from `LogEvent` interface and yield sites - Fix `--agent` flag test to use multi-agent context for proper disambiguation - Remove dead `--agent-id` option that was registered but never wired up Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
853b072 to
ef1e369
Compare
Contributor
Author
|
Discussion: I think we should go into the template agent experience and see the logs and otel logs we are providing. Currently the logs command just returns the logs from the runtime log group. This gives the developer the ability to configure logs in there agent how they want and the agentcore cli aligns with there configuration. Right now the otel logs are verbose and it would help to do a deep dive on how the default agent is outputting logs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add a new
agentcore logscommand that provides real-time streaming and historical search of agent runtime logs via CloudWatch Logs.Stream mode (default): Uses
StartLiveTailfor real-time log streaming with auto-reconnect on 3-hour session timeout. Simply runagentcore logsto start streaming.Search mode (
--since/--until): UsesFilterLogEventswith pagination for bounded time-range queries. Supports relative durations (5m,1h,2d), ISO 8601 timestamps, and epoch ms.Filtering: Server-side filtering via
--level(error/warn/info/debug) and--query(free-text). These use CloudWatch filter patterns for efficient server-side filtering.Output: Human-readable by default (ISO timestamp + message), or JSON Lines with
--jsonfor piping to other tools.New files
src/cli/commands/logs/— Command registration, action handler, types, time parser, filter pattern builder, barrel exportsrc/cli/aws/cloudwatch.ts— CloudWatch Logs client withstreamLogs()andsearchLogs()async generatorssrc/cli/commands/logs/__tests__/— 32 unit tests covering time parsing, filter patterns, mode detection, formatting, and agent resolutionModified files
src/cli/cli.ts— Registerlogscommandsrc/cli/tui/copy.ts— Add command descriptionsrc/cli/aws/index.ts— Export cloudwatch modulepackage.json— Add@aws-sdk/client-cloudwatch-logsdependency.gitignore— Scopelogspattern to top-level only (was blockingsrc/cli/commands/logs/)Related Issue
N/A — New feature
Closes #373
screenshots of experience
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsManual E2E testing performed with valid AWS credentials:
--agent, unknown agent name, invalid--level, invalid--since--since,--until,--level,--query,--json,-n(line limit), ISO 8601 timestampsStartLiveTailconnects and streams (tested with real log group, confirmed "Streaming logs..." message and clean Ctrl+C handling)Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.