feat(monit): datasource query tools; rework monit-query onto tools invoke - #185
Merged
Merged
Conversation
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.
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.
Summary
Two changes on one branch:
<type>.querytool family into the CLI: Flashduty MonitorsPOST /monit/datasource/tools/invokenow supports query tools (prometheus / mysql / postgres / oracle / clickhouse / elasticsearch / loki / victorialogs / sls / tencent_cls) alongside diagnostic tools.monit-queryonto the tool-invoke entry: query is just a tool. The curatedmonit-querygroup becomes a leaf command,fduty monit-query <datasource-id> --tool '<name>' [--account-id <id>] [--params '<json>'], callingDataSources.ToolsInvokewith raw-JSON params passthrough. The oldmonit-query datasubcommand (/monit/query/data) is retired from the CLI; the generatedmonit query-dataspec mirror stays untouched until the spec retires the endpoint.Merge order: flashduty-docs#380 → go-flashduty#75 → this PR → fc-safari.
Changes
Commit 1 — SDK pin + regeneration + cards
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.go run ./internal/cmd/cligen):zz_generated_*refreshed.monit datasource-tools-invokehelp no longer says "mysql.query and postgres.query are unsupported";--toolhelp documents the ten<type>.querytools and their per-datasource params schemas. Rule commands move torule-v2-create/info/update;rule-counter-nodeandrule-dstypesare dropped per the SDK.monit-datasource.mdgained the<type>.querysection;monit-rule.mdhandwritten sections updated for the rule v2 migration (required formake check-cards);member.md/rum.md/schedule.mdfence resync only.TestDatasourceToolInvokeQueryParamsPreserveJSON.Commit 2 — monit-query rework
internal/cli/monit_query.go: rewritten as a leaf commandmonit-query <datasource-id> --tool <name> [--params '<json>' | -].--paramsis validated as a single JSON object but sent byte-exact (json.RawMessagepassthrough — epoch-ms integers above 2^53 keep their digits); omitted--paramssends noparamsfield; explicit null is rejected. No tool-name or per-datasource params validation client-side (server is the authority). Output reusesdatasourceToolOutputviaprintGenericResult(JSON byte-exact; table/toon precision-preserving).newMonitQueryDataCmd,normalizeRawTimeArgs, andparseKVSlice(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-idstamping, input rejection with zero requests, API error passthrough without replay, and retired-subcommand rejection.monit-query.mdrewritten around the unified tool command (prometheus.query + diagnostic examples, explore_result.v1 result shape);monit-datasource.mdandmonit-probe.mdpoint tool invocation atmonit-querywithdatasource-tools-invokenoted as the spec-mirror equivalent. GENERATED fences re-synced viamake gen-cards./monit/query/dataandquery_result.v1still 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.