Skip to content

feat(monitor): port Monitor V2 commands from Go CLI#18

Draft
beengud wants to merge 1 commit into
mainfrom
feat/monitorv2
Draft

feat(monitor): port Monitor V2 commands from Go CLI#18
beengud wants to merge 1 commit into
mainfrom
feat/monitorv2

Conversation

@beengud

@beengud beengud commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Closes #6

Ported surface — observe monitor

Command GraphQL op Output
monitor list [<name-substring>] searchMonitorV2 table/json/csv (id, name, disabled, updatedDate)
monitor get <id> monitorV2 human summary + full definition (json/csv for raw)
monitor preview-query <file.json> evaluateMonitorV2Source compiled OPAL pipeline (per-stage) + output stage
monitor preview [--workspace <id>] [--since <dur>] <file.json> previewMonitorV2 "Would fire: true/false" + sample alarm groupings
monitor alarms [--workspace] [--monitor-id] [--since] [--level] searchMonitorV2Alarms table/json/csv (id, monitorId, level, status, startTime, endTime)

Input JSON is MonitorV2Input (min: name, ruleKind, definition). All commands support --format json|csv.

Field-name corrections vs the Go CLI (the Go queries were written against an older schema)

The published SDL (terraform-provider-observe) differs substantially from the Go fork's hand-written queries. Corrections made to match the authoritative schema:

  • searchMonitorV2 / searchMonitorV2Alarms return results, not monitors / alarms.
  • previewMonitorV2 requires a params: QueryParams! arg (Go omitted it) and returns MonitorV2Preview { alarms, stabilityBookmarkTime, alertSchema } — there is no wouldFire / samples. "Would fire" is derived as alarms.length > 0; groupings come from each alarm's context / capturedValues.
  • searchMonitorV2Alarms args are monitorIds: [ObjectId!], minTime/maxTime (Go used monitorId, startTime/endTime). MonitorV2Alarm has no monitorId/statusmonitorId comes from monitor { id } and status is derived from isActive (Active/Ended).
  • evaluateMonitorV2Source returns MonitorV2SourceEvaluation { query: MultiStageQuery! } — there is no pipeline / resultSchema; the OPAL is in query.stages[].pipeline.
  • searchMonitorV2/previewMonitorV2/searchMonitorV2Alarms take workspaceId: ObjectId (nullable) → exposed via optional --workspace (the new CLI Config has no workspace).
  • MonitorV2AlarmLevel enum values are capitalized (Critical/Error/Warning/Informational); --level accepts lowercase and normalizes.

monitor get renders a human summary by default (no yaml dependency in the repo); --format json emits the full monitor incl. definition.

Verification

  • Codegen: scoped graphql-code-generator against the published SDL ends ✔ Generate — all five operations validate against the schema with zero document errors.
  • Typecheck: scoped tsc --noEmit is clean for src/commands/monitor and src/gql/monitor (only unrelated bun:test/other-resource noise outside the feature).
  • Tests: bun test src/commands/monitor/18 pass / 0 fail across 5 files.

🤖 Generated with Claude Code

Add `observe monitor` with list, get, preview-query, preview, and alarms
subcommands backed by the published monitorV2 GraphQL operations.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port monitor (Monitor V2) commands from the Go fork

2 participants