feat(block): Add cloudwatch block#3911
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Implements new Wires up UI support via a new Written by Cursor Bugbot for commit 68d9174. This will update automatically on new commits. Configure here. |
Greptile SummaryThis PR adds a CloudWatch integration block to Sim, covering 7 operations: Query Logs (Insights), Describe Log Groups, Get Log Events, Describe Log Streams, List Metrics, Get Metric Statistics, and Describe Alarms. The implementation follows the established integration pattern (tools → block → icon → API routes) and is well-structured overall — type definitions are clean, Zod validation is consistent, credentials use Key findings:
Confidence Score: 5/5Safe to merge — all findings are P2 style/best-practice issues that do not affect runtime correctness or data integrity. The integration is fully functional, tested locally, and follows the established block/tool/route pattern correctly. The three flagged issues are all non-blocking: relative imports in a barrel file, a polling timeout concern that depends on deployment configuration, and inconsistent logger usage. None introduce bugs, security holes, or broken user paths. apps/sim/tools/cloudwatch/index.ts (relative imports) and apps/sim/app/api/tools/cloudwatch/utils.ts (60s polling loop) Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as Block UI
participant Selector as Selector (Registry)
participant LogGroupsAPI as /api/tools/cloudwatch/describe-log-groups
participant LogStreamsAPI as /api/tools/cloudwatch/describe-log-streams
participant ExecutionEngine as Executor
participant ToolAPI as /api/tools/cloudwatch/{operation}
participant AWS as AWS CloudWatch
UI->>Selector: Populate log group dropdown (awsAccessKeyId, awsRegion, awsSecretAccessKey)
Selector->>LogGroupsAPI: POST (checkSessionOrInternalAuth)
LogGroupsAPI->>AWS: DescribeLogGroupsCommand
AWS-->>LogGroupsAPI: logGroups[]
LogGroupsAPI-->>Selector: { output: { logGroups } }
Selector-->>UI: Dropdown options
UI->>Selector: Populate log stream dropdown (+ logGroupName)
Selector->>LogStreamsAPI: POST (checkSessionOrInternalAuth)
LogStreamsAPI->>AWS: DescribeLogStreamsCommand
AWS-->>LogStreamsAPI: logStreams[]
LogStreamsAPI-->>Selector: { output: { logStreams } }
Selector-->>UI: Dropdown options
ExecutionEngine->>ToolAPI: POST (checkInternalAuth) — selected operation
alt query_logs
ToolAPI->>AWS: StartQueryCommand
AWS-->>ToolAPI: queryId
loop Poll up to 60s
ToolAPI->>AWS: GetQueryResultsCommand(queryId)
AWS-->>ToolAPI: status / results
end
else get_log_events
ToolAPI->>AWS: GetLogEventsCommand
AWS-->>ToolAPI: events[]
else get_metric_statistics
ToolAPI->>AWS: GetMetricStatisticsCommand
AWS-->>ToolAPI: Datapoints[]
else describe_alarms
ToolAPI->>AWS: DescribeAlarmsCommand
AWS-->>ToolAPI: MetricAlarms[] + CompositeAlarms[]
end
ToolAPI-->>ExecutionEngine: { success, output }
Reviews (1): Last reviewed commit: "Fix bun lock" | Re-trigger Greptile |
apps/sim/tools/cloudwatch/index.ts
Outdated
| import { describeAlarmsTool } from './describe_alarms' | ||
| import { describeLogGroupsTool } from './describe_log_groups' | ||
| import { describeLogStreamsTool } from './describe_log_streams' | ||
| import { getLogEventsTool } from './get_log_events' | ||
| import { getMetricStatisticsTool } from './get_metric_statistics' | ||
| import { listMetricsTool } from './list_metrics' | ||
| import { queryLogsTool } from './query_logs' |
There was a problem hiding this comment.
Relative imports violate absolute-import rule
All seven imports in the barrel file use relative paths (./describe_alarms, etc.). Per the project's import conventions, absolute imports must always be used — relative imports are prohibited.
| import { describeAlarmsTool } from './describe_alarms' | |
| import { describeLogGroupsTool } from './describe_log_groups' | |
| import { describeLogStreamsTool } from './describe_log_streams' | |
| import { getLogEventsTool } from './get_log_events' | |
| import { getMetricStatisticsTool } from './get_metric_statistics' | |
| import { listMetricsTool } from './list_metrics' | |
| import { queryLogsTool } from './query_logs' | |
| import { describeAlarmsTool } from '@/tools/cloudwatch/describe_alarms' | |
| import { describeLogGroupsTool } from '@/tools/cloudwatch/describe_log_groups' | |
| import { describeLogStreamsTool } from '@/tools/cloudwatch/describe_log_streams' | |
| import { getLogEventsTool } from '@/tools/cloudwatch/get_log_events' | |
| import { getMetricStatisticsTool } from '@/tools/cloudwatch/get_metric_statistics' | |
| import { listMetricsTool } from '@/tools/cloudwatch/list_metrics' | |
| import { queryLogsTool } from '@/tools/cloudwatch/query_logs' |
Rule Used: Use established path alias patterns instead of dee... (source)
Learnt From
simstudioai/sim#233
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
* 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>

Summary
Add block for cloudwatch operations.
Type of Change
Testing
Checklist
Screenshots/Videos