feat(block): Add cloudwatch block #3953
Conversation
* feat(block): add cloudwatch integration * Fix bun lock * Add logger, use execution timeout * Switch metric dimensions to map style input * Fix attribute names for dimension map * Fix import styling --------- Co-authored-by: Theodore Li <theo@sim.ai>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Introduces new Next.js API routes under Extends selector infrastructure to support CloudWatch log group/stream pickers (new selector keys and additional AWS fields in selector context), and adds AWS SDK dependencies plus a new Reviewed by Cursor Bugbot for commit 498504c. Bugbot is set up for automated code reviews on this repo. Configure here. |
Greptile SummaryThis PR adds a fully-featured AWS CloudWatch block supporting seven operations: Query Logs (Insights), Describe Log Groups, Get Log Events, Describe Log Streams, List Metrics, Get Metric Statistics, and Describe Alarms. It follows the project's integration checklist closely — tools, block config, icon, selector entries, and API routes are all present and registered correctly. Key highlights:
Confidence Score: 4/5Safe to merge after addressing two minor style issues; no functional or security regressions introduced. All seven operations are correctly implemented end-to-end, credentials use the correct 'user-only' visibility, and the selector integration works. Two P2 findings remain: import-after-const in three route files and a missing awsSecretAccessKey in both selector cache keys. Neither causes a runtime failure but both represent small correctness/style gaps. apps/sim/app/api/tools/cloudwatch/query-logs/route.ts, apps/sim/app/api/tools/cloudwatch/get-log-events/route.ts, apps/sim/app/api/tools/cloudwatch/describe-log-streams/route.ts (import order), and apps/sim/hooks/selectors/registry.ts (query key completeness). Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Block UI
participant Exec as Executor
participant Route as API Route
participant AWS as AWS SDK
UI->>Exec: Run workflow (operation + params)
Exec->>Route: POST /api/tools/cloudwatch/{operation}
Route->>Route: checkInternalAuth / checkSessionOrInternalAuth
Route->>Route: Zod schema validation
Route->>AWS: AWS SDK command (CloudWatchLogsClient / CloudWatchClient)
AWS-->>Route: Response
alt query_logs
Route->>Route: pollQueryResults (polls until Complete/timeout)
end
Route-->>Exec: { success, output }
Exec-->>UI: Block output
UI->>Route: POST /api/tools/cloudwatch/describe-log-groups (file-selector)
Note over Route: checkSessionOrInternalAuth (session needed for UI)
Route->>AWS: DescribeLogGroupsCommand
AWS-->>Route: logGroups[]
Route-->>UI: { output: { logGroups } }
UI->>Route: POST /api/tools/cloudwatch/describe-log-streams (file-selector)
Note over Route: checkSessionOrInternalAuth
Route->>AWS: DescribeLogStreamsCommand
AWS-->>Route: logStreams[]
Route-->>UI: { output: { logStreams } }
Reviews (1): Last reviewed commit: "feat(block): Add cloudwatch block (#3911..." | Re-trigger Greptile |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 498504c. Configure here.
| timestamp: e.timestamp, | ||
| message: e.message, | ||
| ingestionTime: e.ingestionTime, | ||
| })), |
There was a problem hiding this comment.
Inconsistent timestamp units in log event output
Medium Severity
The getLogEvents utility returns timestamp and ingestionTime in milliseconds, inconsistent with its startTime/endTime inputs (seconds) and other CloudWatch utilities like getMetricStatistics (seconds output). This unit mismatch, also seen in describeLogStreams and describeAlarms outputs, can cause downstream consumers to misinterpret or incorrectly use timestamp values.
Reviewed by Cursor Bugbot for commit 498504c. Configure here.


Summary
Add block for cloudwatch operations. Second time's the charm!
Type of Change
Testing
Checklist
Screenshots/Videos