diff --git a/internal/cli/coverage_test.go b/internal/cli/coverage_test.go index e225b56..192652e 100644 --- a/internal/cli/coverage_test.go +++ b/internal/cli/coverage_test.go @@ -24,6 +24,14 @@ var curatedOperationIDs = map[string]bool{ "automation-trigger-write-fire": true, } +// retiredOperationIDs bridges the release window where the server-side route +// is gone but the CLI still compiles against the previous released SDK spec. +var retiredOperationIDs = map[string]bool{ + "monit-preview-sync": true, + "monit-read-query-rows": true, + "monit-rule-write-status": true, +} + // loadSpecOps reads every public GET/POST operation from the openapi spec // shipped in the linked go-flashduty module — the same spec cligen generates // against — recording each op's id, path, and whether its 200 response is a @@ -80,6 +88,9 @@ func loadSpecPaths(t *testing.T) map[string]string { t.Helper() ids := map[string]string{} for _, op := range loadSpecOps(t) { + if retiredOperationIDs[op.id] { + continue + } ids[op.id] = op.path } return ids @@ -158,6 +169,9 @@ func TestGeneratorTargetsFullSpec(t *testing.T) { curated := map[string]bool{} wantGenerated := map[string]bool{} for _, op := range ops { + if retiredOperationIDs[op.id] { + continue + } if op.streaming { streaming[op.id] = true continue diff --git a/internal/cli/monit_query.go b/internal/cli/monit_query.go index db70eb2..bc2d78f 100644 --- a/internal/cli/monit_query.go +++ b/internal/cli/monit_query.go @@ -1,7 +1,6 @@ package cli import ( - "encoding/json" "fmt" "strconv" @@ -15,7 +14,6 @@ func newMonitQueryCmd() *cobra.Command { cmd := newGroupCmd("monit-query", "Probe monit-backed datasources (9 types via data; diagnose: loki|victorialogs log patterns, prometheus metric trends)") cmd.AddCommand(newMonitQueryDiagnoseCmd()) cmd.AddCommand(newMonitQueryDataCmd()) - cmd.AddCommand(newMonitQueryRowsCmd()) return cmd } @@ -135,74 +133,8 @@ func newMonitQueryDataCmd() *cobra.Command { return cmd } -func newMonitQueryRowsCmd() *cobra.Command { - var ( - dsType, dsName, expr string - argsKV []string - ) - - cmd := &cobra.Command{ - Use: "rows", - Short: "Raw datasource passthrough (returns values/rows as the datasource itself would). Deprecated — prefer 'monit-query data'", - Deprecated: "use 'monit-query data' instead", - Long: curatedLong("Deprecated. Raw datasource passthrough returning values/rows as the datasource itself would. Migrate to 'monit-query data', which preserves frames/records/samples without forcing results into legacy rows.", "Diagnostics", "QueryRows"), - RunE: func(cmd *cobra.Command, args []string) error { - if dsType == "" || dsName == "" || expr == "" { - return fmt.Errorf("--ds-type, --ds-name, --expr are required") - } - argsMap, err := parseKVSlice(argsKV) - if err != nil { - return fmt.Errorf("invalid --args: %w", err) - } - if err := normalizeRawTimeArgs(dsType, argsMap); err != nil { - return err - } - - return runCommand(cmd, args, func(ctx *RunContext) error { - input := &flashduty.QueryRowsRequest{ - DsType: dsType, - DsName: dsName, - Expr: expr, - Args: argsMap, - } - result, _, err := ctx.Client.Diagnostics.QueryRows(cmdContext(ctx.Cmd), input) - if err != nil { - return err - } - // This command is a raw datasource passthrough. The legacy SDK - // captured the response body (a JSON array of {fields,values} - // objects) as a RawMessage and wrote it through verbatim, - // independent of the --json/--toon output format. go-flashduty - // decodes that same array into []QueryRow, so re-marshal it to - // the equivalent JSON array and write it through unchanged to - // preserve the legacy single-blob output shape. - if result == nil { - _, err = fmt.Fprintln(ctx.Writer, "{}") - return err - } - body, err := json.Marshal(*result) - if err != nil { - return fmt.Errorf("failed to marshal query rows: %w", err) - } - _, err = fmt.Fprintln(ctx.Writer, string(body)) - return err - }) - }, - } - - cmd.Flags().StringVar(&dsType, "ds-type", "", "Datasource type (required)") - cmd.Flags().StringVar(&dsName, "ds-name", "", "Datasource name (required)") - registerEnumFlag(cmd, "ds-type", "prometheus", "victorialogs", "loki", "mysql") - cmd.Flags().StringVar(&expr, "expr", "", "Query expression (required)") - cmd.Flags().StringSliceVar(&argsKV, "args", nil, "Arg entries KEY=VALUE (repeatable; values must be strings per monit-query contract). "+ - "For loki/victorialogs raw mode, .start/.end accept a relative duration ('15m'), 'now', a date/RFC3339 timestamp, "+ - "or a unix epoch in seconds or milliseconds — normalized to the form the datasource requires before sending") - - return cmd -} - // normalizeRawTimeArgs rewrites the raw-mode time-window args of a -// monit-query rows call (.start / .end) into the unix- +// monit-query data call (.start / .end) into the unix- // seconds form the server requires, accepting any format timeutil.Parse // understands (RFC3339, date/datetime, relative duration, unix seconds or // milliseconds). Loki and VictoriaLogs are the only ds-types whose raw mode diff --git a/internal/cli/monit_query_test.go b/internal/cli/monit_query_test.go index e958d6e..7da20b8 100644 --- a/internal/cli/monit_query_test.go +++ b/internal/cli/monit_query_test.go @@ -22,15 +22,6 @@ func TestMonitQueryDiagnoseFlags(t *testing.T) { } } -func TestMonitQueryRowsFlags(t *testing.T) { - cmd := newMonitQueryRowsCmd() - for _, name := range []string{"ds-type", "ds-name", "expr", "args"} { - if cmd.Flags().Lookup(name) == nil { - t.Errorf("flag --%s missing", name) - } - } -} - func TestMonitQueryDataFlags(t *testing.T) { cmd := newMonitQueryDataCmd() for _, name := range []string{"ds-type", "ds-name", "expr", "args", "delay-seconds"} { @@ -209,7 +200,7 @@ func TestMonitQueryDiagnoseInvalidTimeStart(t *testing.T) { } } -// --- monit-query rows ----------------------------------------------------- +// --- monit-query data ----------------------------------------------------- func TestMonitQueryDataHappyPath(t *testing.T) { saveAndResetGlobals(t) @@ -309,96 +300,6 @@ func TestMonitQueryDataRequiredFlags(t *testing.T) { } } -func TestMonitQueryRowsHappyPath(t *testing.T) { - saveAndResetGlobals(t) - stub := newGFStub(t) - // rows is a raw datasource passthrough: the response envelope "data" is a - // JSON array of QueryRow ({fields,values}) objects, decoded into - // QueryRowsResponse ([]QueryRow) and re-marshalled verbatim to the writer. - stub.data = []any{ - map[string]any{ - "fields": map[string]any{"instance": "node-1"}, - "values": map[string]any{"__value__": 1}, - }, - } - - out, err := execCommand( - "monit-query", "rows", - "--ds-type", "prometheus", - "--ds-name", "prom-prod", - "--expr", "up", - "--args", "step=15s", - "--args", "tenant=acme", - ) - if err != nil { - t.Fatalf("unexpected error: %v", err) - } - if stub.lastPath != "/monit/query/rows" { - t.Fatalf("expected /monit/query/rows, got %q", stub.lastPath) - } - body := stub.lastBody - if body["ds_type"] != "prometheus" || body["ds_name"] != "prom-prod" || body["expr"] != "up" { - t.Errorf("unexpected rows input: %#v", body) - } - args, _ := body["args"].(map[string]any) - if args["step"] != "15s" || args["tenant"] != "acme" { - t.Errorf("expected args step=15s tenant=acme, got %#v", args) - } - // The rendered output is the re-marshalled row array (passthrough shape). - if !strings.Contains(out, "node-1") || !strings.Contains(out, "__value__") { - t.Errorf("expected rendered rows to carry the datasource payload, got:\n%s", out) - } -} - -func TestMonitQueryRowsRequiredFlags(t *testing.T) { - cases := []struct { - name string - args []string - }{ - { - name: "missing ds-type", - args: []string{ - "monit-query", "rows", - "--ds-name", "prom-prod", - "--expr", "up", - }, - }, - { - name: "missing ds-name", - args: []string{ - "monit-query", "rows", - "--ds-type", "prometheus", - "--expr", "up", - }, - }, - { - name: "missing expr", - args: []string{ - "monit-query", "rows", - "--ds-type", "prometheus", - "--ds-name", "prom-prod", - }, - }, - } - for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { - saveAndResetGlobals(t) - stub := newGFStub(t) - - _, err := execCommand(tc.args...) - if err == nil { - t.Fatal("expected required-flag error, got nil") - } - if !strings.Contains(err.Error(), "required") { - t.Errorf("expected error to mention 'required', got %q", err.Error()) - } - if stub.requests != 0 { - t.Errorf("rows should not have been called: %d request(s)", stub.requests) - } - }) - } -} - // --- normalizeRawTimeArgs -------------------------------------------------- func TestNormalizeRawTimeArgsAcceptedFormats(t *testing.T) { @@ -469,17 +370,17 @@ func TestNormalizeRawTimeArgsInvalidValue(t *testing.T) { } } -// TestMonitQueryRowsRawModeNormalizesRFC3339 is the regression test for the +// TestMonitQueryDataRawModeNormalizesRFC3339 is the regression test for the // raw-vs-stats time format inconsistency: a raw-mode VictoriaLogs query given // RFC3339 --args timestamps must reach the server as the unix-seconds form // the raw query path requires. -func TestMonitQueryRowsRawModeNormalizesRFC3339(t *testing.T) { +func TestMonitQueryDataRawModeNormalizesRFC3339(t *testing.T) { saveAndResetGlobals(t) stub := newGFStub(t) - stub.data = []any{} + stub.data = map[string]any{"format": "query_result.v1", "result": map[string]any{"kind": "records", "records": []any{}}} _, err := execCommand( - "monit-query", "rows", + "monit-query", "data", "--ds-type", "victorialogs", "--ds-name", "vl-prod", "--expr", `{app="api"} |= "error"`, @@ -534,25 +435,3 @@ func TestMonitQueryDataInvalidArgs(t *testing.T) { t.Errorf("data should not have been called: %d request(s)", stub.requests) } } - -func TestMonitQueryRowsInvalidArgs(t *testing.T) { - saveAndResetGlobals(t) - stub := newGFStub(t) - - _, err := execCommand( - "monit-query", "rows", - "--ds-type", "prometheus", - "--ds-name", "prom-prod", - "--expr", "up", - "--args", "no-equals-sign", - ) - if err == nil { - t.Fatal("expected error for malformed --args, got nil") - } - if !strings.Contains(err.Error(), "--args") { - t.Errorf("expected error to mention --args, got %q", err.Error()) - } - if stub.requests != 0 { - t.Errorf("rows should not have been called: %d request(s)", stub.requests) - } -} diff --git a/internal/cli/zz_generated_alert_rules.go b/internal/cli/zz_generated_alert_rules.go index 38ea836..9f7f723 100644 --- a/internal/cli/zz_generated_alert_rules.go +++ b/internal/cli/zz_generated_alert_rules.go @@ -1211,56 +1211,6 @@ Response fields ('data' is a TOP-LEVEL array of these row objects — pipe 'jq ' return cmd } -func genAlertRulesWriteStatusCmd() *cobra.Command { - var dataJSON string - var fFolderID int64 - cmd := &cobra.Command{ - Use: "rule-status", - Short: "Get rule trigger status under folder", - Long: `Get rule trigger status under folder. - -Return the rule trigger summary for all rules under a folder node and its descendants. - -API: POST /monit/rule/status (monit-rule-write-status) - -Request fields: - --folder-id int — Folder ID to summarize. Obtainable via 'POST /monit/folder/list'. Trigger statistics are returned grouped by direct child folder. - -Response fields ('data' is a TOP-LEVEL array of these row objects — pipe 'jq '.[]'', NOT '.items[]'): - - folder_id (integer) (required) — ID of the folder (grouping node). - - folder_name (string) — Folder name; omitted by some endpoints ('omitempty'). - - rule_total (integer) (required) — Total rules in the folder family. - - triggered_rule_count (integer) (required) — Rules with active alerts. -`, - Example: ` flashduty monit rule-status --data '{"folder_id":100}'`, - RunE: func(cmd *cobra.Command, args []string) error { - return runCommand(cmd, args, func(ctx *RunContext) error { - body, err := genAssembleBody(dataJSON, func(body map[string]any) error { - if cmd.Flags().Changed("folder-id") { - body["folder_id"] = fFolderID - } - return nil - }) - if err != nil { - return err - } - req := new(flashduty.RuleFolderIDRequest) - if err := genBindBody(body, req); err != nil { - return err - } - out, _, err := ctx.Client.AlertRules.WriteStatus(cmdContext(ctx.Cmd), req) - if err != nil { - return err - } - return printGenericResult(ctx, out) - }) - }, - } - cmd.Flags().Int64Var(&fFolderID, "folder-id", 0, "Folder ID to summarize. Obtainable via 'POST /monit/folder/list'. Trigger statistics are returned grouped by direct child folder.") - cmd.Flags().StringVar(&dataJSON, "data", "", "Full request body as JSON; positional arguments and typed flags override its fields. Accepts inline JSON, or - to read stdin.") - return cmd -} - func genAlertRulesWriteUpdateCmd() *cobra.Command { var dataJSON string var fAccountID int64 @@ -1582,6 +1532,5 @@ func registerGeneratedAlertRules(root *cobra.Command) { genAddLeaf(gMonit, genAlertRulesWriteFieldsUpdateCmd()) genAddLeaf(gMonit, genAlertRulesWriteImportCmd()) genAddLeaf(gMonit, genAlertRulesWriteMoveCmd()) - genAddLeaf(gMonit, genAlertRulesWriteStatusCmd()) genAddLeaf(gMonit, genAlertRulesWriteUpdateCmd()) } diff --git a/internal/cli/zz_generated_diagnostics.go b/internal/cli/zz_generated_diagnostics.go index 339043c..c59626c 100644 --- a/internal/cli/zz_generated_diagnostics.go +++ b/internal/cli/zz_generated_diagnostics.go @@ -262,80 +262,6 @@ Response fields ('data' envelope is unwrapped — these fields are at the top le return cmd } -func genDiagnosticsQueryRowsCmd() *cobra.Command { - var dataJSON string - var fAccountID int64 - var fDelaySeconds int64 - var fDsName string - var fDsType string - var fExpr string - cmd := &cobra.Command{ - Use: "query-rows", - Short: "Query data source rows", - Deprecated: "use 'monit-query data' instead", - Long: `Query data source rows. - -Deprecated. Run a synchronous ad-hoc query and return the historical flattened rows shape. Existing consumers should migrate to '/monit/query/data', which preserves frames, records, and samples without forcing every result into legacy rows. - -API: POST /monit/query/rows (monit-read-query-rows) - -Request fields: - --account-id int — Optional consistency check. Must equal the authenticated account when supplied; mismatched values are rejected. Business execution always uses the authenticated account. - --delay-seconds int — Look-back offset in seconds applied to point-in-time queries (Prometheus, Loki stats, VictoriaLogs stats). Ignored for raw / detail queries. - --ds-name string (required) — Data source name; must match a configured data source under the tenant. - --ds-type string (required) — Data source type; must match a configured data source under the tenant. Examples: 'prometheus', 'loki', 'victorialogs', 'sls', 'elasticsearch', 'mysql', 'postgres', 'oracle', 'clickhouse'. - --expr string (required) — Query expression. Syntax depends on 'ds_type' and is interpreted by the corresponding monit-edge client (PromQL for Prometheus, LogQL for Loki, SQL for SQL sources, etc.). - args (object, via --data) — Polymorphic key/value extension parameters forwarded verbatim to monit-edge. All values must be strings, and keys are always namespaced by source (e.g. 'sls.project', 'loki.type'). Validation depends on 'ds_type': SLS requires 'sls.project' + 'sls.logstore'. Elasticsearch accepts 'es.type' of 'sql', or omitted — any other value is rejected. Loki and VictoriaLogs accept '.type' of 'stats', 'raw', or omitted; 'raw' additionally requires a time range, either '.start' + '.end' or '.timespan.value' + '.timespan.unit' (unit one of 's', 'm', 'h', 'd'). Prometheus and the remaining SQL sources ignore 'args' entirely. - -Response fields ('data' is a TOP-LEVEL array of these row objects — pipe 'jq '.[]'', NOT '.items[]'): - - fields (object) — String-valued fields (labels, log fields, SQL columns). - - values (object) — Numeric fields. For metric queries the canonical key is '__value__'. May be 'null' for detail-oriented sources. -`, - Example: ` flashduty monit query-rows --data '{"account_id":10001,"delay_seconds":30,"ds_name":"prod-prom","ds_type":"prometheus","expr":"up"}'`, - RunE: func(cmd *cobra.Command, args []string) error { - return runCommand(cmd, args, func(ctx *RunContext) error { - body, err := genAssembleBody(dataJSON, func(body map[string]any) error { - if cmd.Flags().Changed("account-id") { - body["account_id"] = fAccountID - } - if cmd.Flags().Changed("delay-seconds") { - body["delay_seconds"] = fDelaySeconds - } - if cmd.Flags().Changed("ds-name") { - body["ds_name"] = fDsName - } - if cmd.Flags().Changed("ds-type") { - body["ds_type"] = fDsType - } - if cmd.Flags().Changed("expr") { - body["expr"] = fExpr - } - return nil - }) - if err != nil { - return err - } - req := new(flashduty.QueryRowsRequest) - if err := genBindBody(body, req); err != nil { - return err - } - out, _, err := ctx.Client.Diagnostics.QueryRows(cmdContext(ctx.Cmd), req) - if err != nil { - return err - } - return printGenericResult(ctx, out) - }) - }, - } - cmd.Flags().Int64Var(&fAccountID, "account-id", 0, "Optional consistency check. Must equal the authenticated account when supplied; mismatched values are rejected. Business execution always uses the authenticated account.") - cmd.Flags().Int64Var(&fDelaySeconds, "delay-seconds", 0, "Look-back offset in seconds applied to point-in-time queries (Prometheus, Loki stats, VictoriaLogs stats). Ignored for raw / detail queries.") - cmd.Flags().StringVar(&fDsName, "ds-name", "", "Data source name; must match a configured data source under the tenant. (required)") - cmd.Flags().StringVar(&fDsType, "ds-type", "", "Data source type; must match a configured data source under the tenant. Examples: 'prometheus', 'loki', 'victorialogs', 'sls', 'elasticsearch', 'mysql', 'postgres', 'oracle', 'clickhouse'. (required)") - cmd.Flags().StringVar(&fExpr, "expr", "", "Query expression. Syntax depends on 'ds_type' and is interpreted by the corresponding monit-edge client (PromQL for Prometheus, LogQL for Loki, SQL for SQL sources, etc.). (required)") - cmd.Flags().StringVar(&dataJSON, "data", "", "Full request body as JSON; positional arguments and typed flags override its fields. Accepts inline JSON, or - to read stdin.") - return cmd -} - func genDiagnosticsTargetsListCmd() *cobra.Command { var dataJSON string var fAccountID int64 @@ -562,7 +488,6 @@ func registerGeneratedDiagnostics(root *cobra.Command) { gMonit := genGroup(root, "monit", "Monitors API") genAddLeaf(gMonit, genDiagnosticsQueryDataCmd()) genAddLeaf(gMonit, genDiagnosticsQueryDiagnoseCmd()) - genAddLeaf(gMonit, genDiagnosticsQueryRowsCmd()) genAddLeaf(gMonit, genDiagnosticsTargetsListCmd()) genAddLeaf(gMonit, genDiagnosticsToolsCatalogCmd()) genAddLeaf(gMonit, genDiagnosticsToolsInvokeCmd()) diff --git a/internal/cli/zz_generated_manifest.go b/internal/cli/zz_generated_manifest.go index 6c7f026..f3a0a08 100644 --- a/internal/cli/zz_generated_manifest.go +++ b/internal/cli/zz_generated_manifest.go @@ -181,10 +181,8 @@ var generatedOpIDs = []string{ "monit-datasource-write-create", "monit-datasource-write-delete", "monit-datasource-write-update", - "monit-preview-sync", "monit-read-query-data", "monit-read-query-diagnose", - "monit-read-query-rows", "monit-read-targets-list", "monit-read-tools-catalog", "monit-read-tools-invoke", @@ -204,7 +202,6 @@ var generatedOpIDs = []string{ "monit-rule-write-fields-update", "monit-rule-write-import", "monit-rule-write-move", - "monit-rule-write-status", "monit-rule-write-update", "monit-servicemap-read-fleet", "monit-servicemap-read-fleet-summary", diff --git a/internal/cli/zz_generated_monitor_utilities.go b/internal/cli/zz_generated_monitor_utilities.go deleted file mode 100644 index 1208054..0000000 --- a/internal/cli/zz_generated_monitor_utilities.go +++ /dev/null @@ -1,81 +0,0 @@ -// Code generated by internal/cmd/cligen; DO NOT EDIT. - -package cli - -import ( - "github.com/spf13/cobra" - - flashduty "github.com/flashcatcloud/go-flashduty" -) - -func genMonitorUtilitiesSyncCmd() *cobra.Command { - var dataJSON string - var fDelaySeconds int64 - var fDsName string - var fDsType string - var fExpr string - cmd := &cobra.Command{ - Use: "preview-sync", - Short: "Preview datasource query", - Long: `Preview datasource query. - -Execute a synchronous datasource query and return the raw result. Used to preview alert rule expressions before saving. - -API: POST /monit/preview/sync (monit-preview-sync) - -Request fields: - --delay-seconds int — Shift the query window backward by this many seconds to compensate for data ingestion latency. - --ds-name string (required) — Datasource display name as configured in the account. - --ds-type string (required) — Datasource type, e.g. 'prometheus', 'loki', 'elasticsearch'. - --expr string (required) — Query expression. Format depends on 'ds_type' (PromQL for Prometheus, LogQL for Loki, etc.). - args (object, via --data) — Additional datasource-type-specific query arguments (string keys and values), e.g. 'sls.project' and 'sls.logstore' for SLS, 'es.type' for Elasticsearch, 'loki.type' and 'loki.limit' for Loki. -`, - Example: ` flashduty monit preview-sync --data '{"delay_seconds":0,"ds_name":"Prometheus Prod","ds_type":"prometheus","expr":"rate(http_requests_total[5m])"}'`, - RunE: func(cmd *cobra.Command, args []string) error { - return runCommand(cmd, args, func(ctx *RunContext) error { - body, err := genAssembleBody(dataJSON, func(body map[string]any) error { - if cmd.Flags().Changed("delay-seconds") { - body["delay_seconds"] = fDelaySeconds - } - if cmd.Flags().Changed("ds-name") { - body["ds_name"] = fDsName - } - if cmd.Flags().Changed("ds-type") { - body["ds_type"] = fDsType - } - if cmd.Flags().Changed("expr") { - body["expr"] = fExpr - } - return nil - }) - if err != nil { - return err - } - req := new(flashduty.PreviewSyncRequest) - if err := genBindBody(body, req); err != nil { - return err - } - resp, err := ctx.Client.MonitorUtilities.Sync(cmdContext(ctx.Cmd), req) - if err != nil { - return err - } - if resp != nil && len(resp.Raw) > 0 { - return ctx.WriteRaw(resp.Raw) - } - ctx.WriteResult("OK: POST /monit/preview/sync") - return nil - }) - }, - } - cmd.Flags().Int64Var(&fDelaySeconds, "delay-seconds", 0, "Shift the query window backward by this many seconds to compensate for data ingestion latency.") - cmd.Flags().StringVar(&fDsName, "ds-name", "", "Datasource display name as configured in the account. (required)") - cmd.Flags().StringVar(&fDsType, "ds-type", "", "Datasource type, e.g. 'prometheus', 'loki', 'elasticsearch'. (required)") - cmd.Flags().StringVar(&fExpr, "expr", "", "Query expression. Format depends on 'ds_type' (PromQL for Prometheus, LogQL for Loki, etc.). (required)") - cmd.Flags().StringVar(&dataJSON, "data", "", "Full request body as JSON; positional arguments and typed flags override its fields. Accepts inline JSON, or - to read stdin.") - return cmd -} - -func registerGeneratedMonitorUtilities(root *cobra.Command) { - gMonit := genGroup(root, "monit", "Monitors API") - genAddLeaf(gMonit, genMonitorUtilitiesSyncCmd()) -} diff --git a/internal/cli/zz_generated_register.go b/internal/cli/zz_generated_register.go index fc99dfb..f9e7ec3 100644 --- a/internal/cli/zz_generated_register.go +++ b/internal/cli/zz_generated_register.go @@ -16,7 +16,6 @@ func registerGenerated(root *cobra.Command) { registerGeneratedAlertRules(root) registerGeneratedDataSources(root) registerGeneratedDiagnostics(root) - registerGeneratedMonitorUtilities(root) registerGeneratedRuleSets(root) registerGeneratedServiceMap(root) registerGeneratedAlertEnrichment(root) diff --git a/internal/cli/zz_generated_response_help.go b/internal/cli/zz_generated_response_help.go index 67ed899..6e98cbd 100644 --- a/internal/cli/zz_generated_response_help.go +++ b/internal/cli/zz_generated_response_help.go @@ -35,7 +35,6 @@ var responseHelpBySDKMethod = map[string]string{ "AlertRules.WriteFieldsUpdate": "Response fields (`data` is a TOP-LEVEL array of these row objects — pipe `jq '.[]'`, NOT `.items[]`):\n - message (string) (required) — Empty on success, error message on failure.\n - name (string) (required) — Rule name.\n", "AlertRules.WriteImport": "Response fields (`data` is a TOP-LEVEL array of these row objects — pipe `jq '.[]'`, NOT `.items[]`):\n - message (string) (required) — Empty on success, error message on failure.\n - name (string) (required) — Rule name.\n", "AlertRules.WriteMove": "Response fields (`data` is a TOP-LEVEL array of these row objects — pipe `jq '.[]'`, NOT `.items[]`):\n - message (string) (required) — Empty on success, error message on failure.\n - name (string) (required) — Rule name.\n", - "AlertRules.WriteStatus": "Response fields (`data` is a TOP-LEVEL array of these row objects — pipe `jq '.[]'`, NOT `.items[]`):\n - folder_id (integer) (required) — ID of the folder (grouping node).\n - folder_name (string) — Folder name; omitted by some endpoints (`omitempty`).\n - rule_total (integer) (required) — Total rules in the folder family.\n - triggered_rule_count (integer) (required) — Rules with active alerts.\n", "AlertRules.WriteUpdate": "Response fields (`data` envelope is unwrapped — these fields are at the top level):\n - account_id (integer) — Account ID. Filled by the server from the authenticated identity; do not provide.\n - annotations (object) — Annotation key-value pairs delivered with alert events; keys must not start with `$` (reserved for query fields).\n - channel_ids (array) — Channel IDs to send alerts to.\n - created_at (integer) — Creation time as a Unix timestamp in seconds. Generated by the server; do not provide.\n - creator_id (integer) — Creator user ID. Filled by the server from the current user; do not provide.\n - creator_name (string) — Creator name. Filled by the server; do not provide.\n - cron_pattern (string) — Schedule expression: a 6-field cron (with seconds) or an `@every 30s` interval descriptor. Must not start with `CRON_TZ=` or `TZ=`; use the `timezone` field instead.\n - debug_log_enabled (boolean) — Whether to enable debug logging; the edge emits detailed evaluation logs, useful for troubleshooting rules that do not trigger as expected.\n - delay_seconds (integer) — Seconds to shift the evaluation query window backward, compensating for data ingestion latency.\n - description (string) — Rule description, in Markdown.\n - description_type (string) — Format for the description. Defaults to `text` when omitted or empty. `text` = plain text; `markdown` = Markdown, rendered as Markdown in alert details. [text, markdown]\n - ds_ids (array) — Datasource IDs, merged with `ds_list` to decide which datasources the rule monitors; IDs survive datasource renames. At least one of `ds_list` and `ds_ids` must be provided.\n - ds_list (array) — Data source name patterns (supports wildcards).\n - ds_type (string) — Datasource type identifier; allowed values are listed by `POST /monit/rule/dstypes` (e.g. `prometheus`, `elasticsearch`).\n - enabled (boolean) — Whether the rule is enabled. Updating to `false` makes the server clean up the rule's active alerts.\n - enabled_times (array) — Time windows when the rule is active. Defaults to all days from 00:00 to 23:59 when omitted or empty.\n - days (array) — Days of week (0=Sunday).\n - etime (string) — End time, e.g. `18:00`.\n - stime (string) — Start time, e.g. `09:00`.\n - folder_id (integer) — ID of the folder the rule belongs to. Obtainable via `POST /monit/folder/list`.\n - id (integer) — Rule ID. Required for update; omit for create (assigned by the server).\n - labels (object) — Custom labels.\n - name (string) — Rule name. Must be unique within the same folder.\n - repeat_interval (integer) — Notification repeat interval in seconds.\n - repeat_total (integer) — Max number of repeat notifications.\n - rule_configs (object) — Check configuration: query list plus trigger/recovery conditions. Structure see `RuleConfigs`.\n - check_anydata (object) — Any-data check configuration. Fires when the query returns any data rows.\n - alerting_check_times (integer) — Number of consecutive evaluations that must satisfy the condition before alerting; minimum 1.\n - enabled (boolean) — Whether any-data checking is enabled: any returned data row triggers an alert.\n - push_recovery_event (boolean) — Whether to push a recovery event notification when the alert resolves.\n - recovery (object) — Recovery condition for any-data check. If omitted or `mode` is empty, treated as `nodata`.\n - args (object) — Datasource-specific options for the recovery query, same convention as `queries[].args`; required for Elasticsearch datasources when `mode` is `ql`.\n - condition (string) — Recovery expression. Required when `mode` is `ql`.\n - mode (string) — `nodata` = recover when the query returns no data; `ql` = recover when the `condition` expression evaluates to true. When `mode` is `ql`, only a single query (`name=A`) is permitted. [nodata, ql]\n - recovery_check_times (integer) — Number of consecutive evaluations that must satisfy the recovery condition before resolving; minimum 1.\n - severity (string) — Severity of any-data alert events; case-sensitive. [Critical, Warning, Info]\n - check_nodata (object) — No-data check configuration.\n - alert_on_empty_result (boolean) — Whether to trigger an alert when every query returns an empty result.\n - alert_on_empty_result_severity (string) — Severity of empty-result alerts, case-sensitive; only effective when `alert_on_empty_result` is enabled. [Critical, Warning, Info]\n - alerting_check_times (integer) — Number of consecutive evaluations that must satisfy the condition before alerting; minimum 1.\n - enabled (boolean) — Whether no-data checking is enabled: a previously-seen series that stops returning data triggers an alert.\n - push_recovery_event (boolean) — Whether to push a recovery event notification when the alert resolves.\n - recovery_check_times (integer) — Number of consecutive evaluations that must satisfy the recovery condition before resolving; minimum 1.\n - resolve_timeout (integer) — Auto-resolve after N seconds.\n - severity (string) — Severity of no-data alert events; case-sensitive. [Critical, Warning, Info]\n - check_threshold (object) — Threshold check configuration.\n - alerting_check_times (integer) — Number of consecutive evaluations that must satisfy the condition before alerting; minimum 1.\n - critical (string) — Critical threshold expression referencing query results via `$` or `$.`, e.g. `$A > 90`; at least one severity must be configured.\n - enabled (boolean) — Whether threshold checking is enabled.\n - info (string) — Info threshold expression, same syntax as `critical`.\n - push_recovery_event (boolean) — Whether to push a recovery event notification when the alert resolves.\n - recovery (object) — Recovery evaluation configuration for threshold checks.\n - condition (string) — Recovery condition expression; required when `mode` is `threshold` or `ql`, and must be empty for `invert`.\n - mode (string) — Recovery mode: `invert` = resolve when the alert expression no longer holds (`condition` stays empty); `threshold` = resolve when the `condition` threshold expression holds; `ql` = resolve when the `condition` query expression evaluates true. [invert, threshold, ql]\n - recovery_check_times (integer) — Number of consecutive evaluations that must satisfy the recovery condition before resolving; minimum 1.\n - warning (string) — Warning threshold expression, same syntax as `critical`.\n - queries (array) — Query list with at least one entry; each needs a unique `name` (`R` and `__all__` are reserved) and a non-empty, non-duplicate `expr`.\n - args (object) — Datasource-specific query options keyed by the `.