Skip to content

feat(monit): datasource query tools; rework monit-query onto tools invoke - #185

Merged
ysyneu merged 4 commits into
mainfrom
feat/monit-datasource-query-tools
Sep 10, 2026
Merged

ysyneu merged 4 commits into
mainfrom
feat/monit-datasource-query-tools

Conversation

@UlricQin

@UlricQin UlricQin commented Sep 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Two changes on one branch:

  1. Absorb the <type>.query tool family into the CLI: Flashduty Monitors POST /monit/datasource/tools/invoke now supports query tools (prometheus / mysql / postgres / oracle / clickhouse / elasticsearch / loki / victorialogs / sls / tencent_cls) alongside diagnostic tools.
  2. Rework monit-query onto the tool-invoke entry: query is just a tool. The curated monit-query group becomes a leaf command, fduty monit-query <datasource-id> --tool '<name>' [--account-id <id>] [--params '<json>'], calling DataSources.ToolsInvoke with raw-JSON params passthrough. The old monit-query data subcommand (/monit/query/data) is retired from the CLI; the generated monit query-data spec mirror stays untouched until the spec retires the endpoint.

Merge blocker: the go-flashduty pin currently points at the head of PR branch feat/monit-datasource-query-tools (commit dce7c88, pseudo-version v0.15.2-0.20260910014922-dce7c882be68). After go-flashduty#75 merges, the pin must be updated to the new commit on main before this PR is merged.

Merge order: flashduty-docs#380 → go-flashduty#75 → this PR → fc-safari.

Changes

Commit 1 — SDK pin + regeneration + cards

  • SDK pin bump: go-flashduty v0.15.1-0.20260908113851-5bf8f2902391 → v0.15.2-0.20260910014922-dce7c882be68 (go-flashduty PR release: merge audit fixes for v1.3.22 #75 head). The bump also pulls in upstream main commits landed after the previous pin: monit rule v2 public APIs (go-flashduty#74, retires v1 rule clients), base-URL path-prefix fix (docs(skills): tighten fduty counting guidance #69), and RUM application remote-config / schedule-by-person operations.
  • Regenerated commands (go run ./internal/cmd/cligen): zz_generated_* refreshed. monit datasource-tools-invoke help no longer says "mysql.query and postgres.query are unsupported"; --tool help documents the ten <type>.query tools and their per-datasource params schemas. Rule commands move to rule-v2-create/info/update; rule-counter-node and rule-dstypes are dropped per the SDK.
  • Skill cards: monit-datasource.md gained the <type>.query section; monit-rule.md handwritten sections updated for the rule v2 migration (required for make check-cards); member.md/rum.md/schedule.md fence resync only.
  • New test TestDatasourceToolInvokeQueryParamsPreserveJSON.

Commit 2 — monit-query rework

  • internal/cli/monit_query.go: rewritten as a leaf command monit-query <datasource-id> --tool <name> [--params '<json>' | -]. --params is validated as a single JSON object but sent byte-exact (json.RawMessage passthrough — epoch-ms integers above 2^53 keep their digits); omitted --params sends no params field; explicit null is rejected. No tool-name or per-datasource params validation client-side (server is the authority). Output reuses datasourceToolOutput via printGenericResult (JSON byte-exact; table/toon precision-preserving).
  • Retired: newMonitQueryDataCmd, normalizeRawTimeArgs, and parseKVSlice (no other users; helper file and its test removed). Old forms (monit-query data ..., monit-query diagnose) now fail before any request.
  • internal/cli/monit_query_test.go: rewritten — raw-body stub asserts path /monit/datasource/tools/invoke, tool identity, params byte fidelity (inline and stdin -), params omission, --account-id stamping, input rejection with zero requests, API error passthrough without replay, and retired-subcommand rejection.
  • Cards: monit-query.md rewritten around the unified tool command (prometheus.query + diagnostic examples, explore_result.v1 result shape); monit-datasource.md and monit-probe.md point tool invocation at monit-query with datasource-tools-invoke noted as the spec-mirror equivalent. GENERATED fences re-synced via make gen-cards.
  • Note: /monit/query/data and query_result.v1 still appear ONLY in generated code/fences mirroring the unchanged spec (zz_generated_diagnostics.go, zz_generated_response_help.go) — no hand-written guidance remains anywhere.

Verification

  • make test (go test -race ./...): all green.
  • make gen-cards + make check-cards: cards OK.
  • go build ./...: OK.

@UlricQin UlricQin changed the title feat(monit): support datasource query tools in invoke command and skill cards feat(monit): datasource query tools; rework monit-query onto tools invoke Sep 10, 2026
The branch pinned a pseudo-version of the SDK PR head; the SDK change is
now released, and generation produces byte-identical output from the tag.
@ysyneu
ysyneu merged commit 95bac72 into main Sep 10, 2026
12 checks passed
@ysyneu
ysyneu deleted the feat/monit-datasource-query-tools branch September 22, 2026 10:03
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.

2 participants