From fee620bc996ea41070c1e34368c84fb2cd7d470d Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Thu, 27 Aug 2026 19:21:07 +0800 Subject: [PATCH] refactor(monitors): remove retired API clients --- alert_rules.go | 14 -- diagnostics.go | 14 -- models_gen.go | 50 ----- monitor_utilities.go | 17 -- openapi/openapi.en.json | 406 ++++------------------------------------ openapi/openapi.zh.json | 406 ++++------------------------------------ roundtrip_gen_test.go | 2 - services_gen.go | 2 - 8 files changed, 78 insertions(+), 833 deletions(-) delete mode 100644 monitor_utilities.go diff --git a/alert_rules.go b/alert_rules.go index 976ee01..e94dbb0 100644 --- a/alert_rules.go +++ b/alert_rules.go @@ -221,20 +221,6 @@ func (s *AlertRulesService) WriteMove(ctx context.Context, req *RuleMoveRequest) return out, resp, nil } -// 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). -func (s *AlertRulesService) WriteStatus(ctx context.Context, req *RuleFolderIDRequest) (*RuleStatusResponse, *Response, error) { - out := new(RuleStatusResponse) - resp, err := s.client.do(ctx, "/monit/rule/status", req, out) - if err != nil { - return nil, resp, err - } - return out, resp, nil -} - // Update alert rule. // // Replace the full configuration of an existing alert rule. All fields are overwritten. diff --git a/diagnostics.go b/diagnostics.go index c0d1152..2500069 100644 --- a/diagnostics.go +++ b/diagnostics.go @@ -35,20 +35,6 @@ func (s *DiagnosticsService) QueryDiagnose(ctx context.Context, req *DiagnoseReq return out, resp, nil } -// 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). -func (s *DiagnosticsService) QueryRows(ctx context.Context, req *QueryRowsRequest) (*QueryRowsResponse, *Response, error) { - out := new(QueryRowsResponse) - resp, err := s.client.do(ctx, "/monit/query/rows", req, out) - if err != nil { - return nil, resp, err - } - return out, resp, nil -} - // List monitored targets. // // List the targets observed under the current tenant by the monit-agent route projection. Supports `target_locator` prefix search and cursor pagination. Use this to drive `target_locator` selection for `/monit/tools/catalog` and `/monit/tools/invoke`. diff --git a/models_gen.go b/models_gen.go index ddc7c30..4069d07 100644 --- a/models_gen.go +++ b/models_gen.go @@ -129,9 +129,6 @@ type OrFilterGroup [][]FilterCondition // PermissionFactorListResponse is a list response payload. type PermissionFactorListResponse []PermissionFactorItem -// QueryRowsResponse is a list response payload. -type QueryRowsResponse []QueryRow - // RuleAuditListResponse is a list response payload. type RuleAuditListResponse []AlertRuleAudit @@ -6064,23 +6061,6 @@ type PreviewIncidentCardFixedField struct { Value string `json:"value" toon:"value"` } -// PreviewSyncRequest is generated from the Flashduty OpenAPI schema. -type PreviewSyncRequest struct { - // 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. - Args map[string]string `json:"args,omitempty" toon:"args,omitempty"` - // Shift the query window backward by this many seconds to compensate for data ingestion latency. - DelaySeconds int64 `json:"delay_seconds,omitempty" toon:"delay_seconds,omitempty"` - // Datasource display name as configured in the account. - DsName string `json:"ds_name" toon:"ds_name"` - // Datasource type, e.g. `prometheus`, `loki`, `elasticsearch`. - DsType string `json:"ds_type" toon:"ds_type"` - // Query expression. Format depends on `ds_type` (PromQL for Prometheus, LogQL for Loki, etc.). - Expr string `json:"expr" toon:"expr"` -} - -// PreviewSyncResponse is generated from the Flashduty OpenAPI schema. -type PreviewSyncResponse struct{} - // PreviewTemplateRequest is generated from the Flashduty OpenAPI schema. type PreviewTemplateRequest struct { // Template content to render. @@ -6176,30 +6156,6 @@ type QueryResult struct { Samples *[]QuerySample `json:"samples,omitempty" toon:"samples,omitempty"` } -// QueryRow is generated from the Flashduty OpenAPI schema. -type QueryRow struct { - // String-valued fields (labels, log fields, SQL columns). - Fields map[string]string `json:"fields" toon:"fields"` - // Numeric fields. For metric queries the canonical key is `__value__`. May be `null` for detail-oriented sources. - Values map[string]float64 `json:"values" toon:"values"` -} - -// QueryRowsRequest is generated from the Flashduty OpenAPI schema. -type QueryRowsRequest struct { - // Optional consistency check. Must equal the authenticated account when supplied; mismatched values are rejected. Business execution always uses the authenticated account. - AccountID int64 `json:"account_id,omitempty" toon:"account_id,omitempty"` - // 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. - Args map[string]string `json:"args,omitempty" toon:"args,omitempty"` - // Look-back offset in seconds applied to point-in-time queries (Prometheus, Loki stats, VictoriaLogs stats). Ignored for raw / detail queries. - DelaySeconds int64 `json:"delay_seconds,omitempty" toon:"delay_seconds,omitempty"` - // Data source name; must match a configured data source under the tenant. - DsName string `json:"ds_name" toon:"ds_name"` - // Data source type; must match a configured data source under the tenant. Examples: `prometheus`, `loki`, `victorialogs`, `sls`, `elasticsearch`, `mysql`, `postgres`, `oracle`, `clickhouse`. - DsType string `json:"ds_type" toon:"ds_type"` - // 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.). - Expr string `json:"expr" toon:"expr"` -} - // QuerySample is generated from the Flashduty OpenAPI schema. type QuerySample struct { // The sample's full label set; may be an empty object but is always present. @@ -6626,12 +6582,6 @@ type RuleFieldsUpdateRequest struct { Timezone string `json:"timezone,omitempty" toon:"timezone,omitempty"` } -// RuleFolderIDRequest is generated from the Flashduty OpenAPI schema. -type RuleFolderIDRequest struct { - // Folder ID to summarize. Obtainable via `POST /monit/folder/list`. Trigger statistics are returned grouped by direct child folder. - FolderID uint64 `json:"folder_id,omitempty" toon:"folder_id,omitempty"` -} - // RuleIDRequest is generated from the Flashduty OpenAPI schema. type RuleIDRequest struct { // Alert rule ID. Obtainable per folder via `POST /monit/rule/list/basic`. diff --git a/monitor_utilities.go b/monitor_utilities.go deleted file mode 100644 index 457d61c..0000000 --- a/monitor_utilities.go +++ /dev/null @@ -1,17 +0,0 @@ -// Code generated by internal/cmd/gen; DO NOT EDIT. - -package flashduty - -import "context" - -// MonitorUtilitiesService handles the "Monitors/Monitor utilities" API resource. -type MonitorUtilitiesService service - -// 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). -func (s *MonitorUtilitiesService) Sync(ctx context.Context, req *PreviewSyncRequest) (*Response, error) { - return s.client.do(ctx, "/monit/preview/sync", req, nil) -} diff --git a/openapi/openapi.en.json b/openapi/openapi.en.json index 4edc9eb..387173d 100644 --- a/openapi/openapi.en.json +++ b/openapi/openapi.en.json @@ -121,10 +121,6 @@ "name": "AI SRE/Sessions", "description": "AI SRE agent session history — list, inspect, and export transcripts." }, - { - "name": "Monitors/Monitor utilities", - "description": "Monitors service activation and data preview utilities." - }, { "name": "AI SRE/Automations" }, @@ -14138,83 +14134,6 @@ } } }, - "/monit/rule/status": { - "post": { - "operationId": "monit-rule-write-status", - "summary": "Get rule trigger status under folder", - "description": "Return the rule trigger summary for all rules under a folder node and its descendants.", - "tags": [ - "Monitors/Alert rules" - ], - "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to get summary across all folders.\n- If the folder contains too many rules, computation is skipped for self-protection.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-status", - "metadata": { - "sidebarTitle": "Get rule trigger status under folder" - } - }, - "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/RuleStatusResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "folder_id": 100, - "folder_name": "Production", - "rule_total": 10, - "triggered_rule_count": 2 - } - ] - } - } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RuleFolderIDRequest" - }, - "example": { - "folder_id": 100 - } - } - } - } - } - }, "/monit/rule/audits": { "post": { "operationId": "monit-rule-read-audits", @@ -19896,7 +19815,7 @@ "Monitors/Diagnostics" ], "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **100 requests/minute**; **5 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n| Edge requirement | Supported deployments require **monit-edge v0.65.0 or later** |\n\n## Usage\n\n- Treat **monit-edge v0.65.0** as the minimum supported Edge version for this public API. WebAPI retains migration adapters for older Edge versions: query.v2 results may still preserve frames, records, or samples, while legacy rows can expose only the information they retained. These adapters do not change the support floor; older protocols lack query.v3 cancellation and error-lifecycle semantics, and data already lost by legacy rows cannot be recovered.\n- The public response format is always `query_result.v1` and is independent of the internal Edge query protocol. Dispatch on `result.kind` (`frames`, `records`, or `samples`); do not infer the result shape from `ds_type` or the Edge version.\n- A `frames` result may contain multiple table or time-series frames. Field values are columnar and all fields in one frame have the same length.\n- A `records` result may contain nested JSON and null records. Integer literals outside JavaScript's safe integer range are returned as decimal strings.\n- A `samples` result contains label sets and instant values. A value may be a number or one of the strings `NaN`, `+Inf`, and `-Inf`.\n- The final success response is limited to 8 MiB and query results are limited to 1,000 rows. Narrow the time range, reduce fields, or aggregate at the source when a request exceeds a limit.\n- Query failures use non-2xx HTTP status codes and the standard error envelope. Do not transparently fall back to the deprecated `/monit/query/rows` endpoint.\n- Query execution may take up to 35 seconds across WebAPI forwarding and Edge execution. Configure client timeouts to at least 40 seconds and propagate cancellation when the caller abandons a query.", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **100 requests/minute**; **5 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n| Edge requirement | Supported deployments require **monit-edge v0.65.0 or later** |\n\n## Usage\n\n- Treat **monit-edge v0.65.0** as the minimum supported Edge version for this public API. WebAPI retains migration adapters for older Edge versions: query.v2 results may still preserve frames, records, or samples, while legacy rows can expose only the information they retained. These adapters do not change the support floor; older protocols lack query.v3 cancellation and error-lifecycle semantics, and data already lost by legacy rows cannot be recovered.\n- The public response format is always `query_result.v1` and is independent of the internal Edge query protocol. Dispatch on `result.kind` (`frames`, `records`, or `samples`); do not infer the result shape from `ds_type` or the Edge version.\n- A `frames` result may contain multiple table or time-series frames. Field values are columnar and all fields in one frame have the same length.\n- A `records` result may contain nested JSON and null records. Integer literals outside JavaScript's safe integer range are returned as decimal strings.\n- A `samples` result contains label sets and instant values. A value may be a number or one of the strings `NaN`, `+Inf`, and `-Inf`.\n- The final success response is limited to 8 MiB and query results are limited to 1,000 rows. Narrow the time range, reduce fields, or aggregate at the source when a request exceeds a limit.\n- Query failures use non-2xx HTTP status codes and the standard error envelope. The legacy `/monit/query/rows` endpoint has been removed; use this endpoint for datasource queries.\n- Query execution may take up to 35 seconds across WebAPI forwarding and Edge execution. Configure client timeouts to at least 40 seconds and propagate cancellation when the caller abandons a query.", "href": "/en/api-reference/monitors/diagnostics/monit-read-query-data", "metadata": { "sidebarTitle": "Query structured data" @@ -20010,92 +19929,6 @@ } } }, - "/monit/query/rows": { - "post": { - "operationId": "monit-read-query-rows", - "summary": "Query data source rows", - "description": "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.", - "deprecated": true, - "tags": [ - "Monitors/Diagnostics" - ], - "x-mint": { - "content": "## Deprecated\n\nUse [`POST /monit/query/data`](/en/api-reference/monitors/diagnostics/monit-read-query-data) for all new integrations. This endpoint remains available only during the migration of existing UI and AI SRE consumers.\n\n## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **100 requests/minute**; **5 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- The request is forwarded to `monit-edge` over WebSocket; the data source named by `ds_type` + `ds_name` must already exist under the calling account.\n- `account_id` in the body is optional. When supplied it must equal the authenticated account; mismatched values are rejected.\n- Validation failures use the standard error envelope. When `monit-edge` rejects a query, its `{\"error\": {\"code\": ..., \"message\": ...}}` body is preserved and the HTTP status matches the edge error code; an invalid or absent code becomes HTTP 500. Check both the status and the error body.\n- monit-edge enforces a row cap; large result sets come back as `error.message = \"too many rows\"`. Narrow the time range or aggregate at the source.\n- `args` is a polymorphic `string→string` map that is forwarded verbatim. Semantics depend on `ds_type` (SLS requires `sls.project` + `sls.logstore`; Loki / VictoriaLogs raw mode requires a time range via `*.start`/`*.end` or `*.timespan.value`/`*.timespan.unit`; Prometheus and SQL sources ignore it). See the monit-webapi query-api docs for the per-source key list.", - "href": "/en/api-reference/monitors/diagnostics/monit-read-query-rows", - "metadata": { - "sidebarTitle": "Query data source rows" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/QueryRowsRequest" - }, - "example": { - "account_id": 10001, - "ds_type": "prometheus", - "ds_name": "prod-prom", - "expr": "up", - "delay_seconds": 30 - } - } - } - }, - "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/QueryRowsResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "fields": { - "__name__": "up", - "instance": "10.0.0.1:9100", - "job": "node" - }, - "values": { - "__value__": 1 - } - } - ] - } - } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - } - } - }, "/monit/query/diagnose": { "post": { "operationId": "monit-read-query-diagnose", @@ -20105,7 +19938,7 @@ "Monitors/Diagnostics" ], "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- This is a diagnostic / RCA endpoint, not a raw data query — pair it with `/monit/query/rows` when you need detailed rows.\n- Only three `ds_type` and `operation` pairs are supported: `loki` / `victorialogs` → `log_patterns`, and `prometheus` → `metric_trends`. Every other datasource is rejected, even when `operation` is explicit.\n- `methods` selects the analyses to run; when omitted, `log_patterns` defaults to `pattern_snapshot + pattern_compare(previous_window)` and `metric_trends` defaults to `single_window_shape + window_compare(previous_window)`.\n- `time_range` is in Unix seconds; missing or invalid values default to the last 15 minutes; a window wider than 6 hours is rejected.\n- The request is forwarded over WebSocket to `monit-edge`. Long-running: the request may take up to ~30 s on the edge side plus webapi overhead. Set client timeouts to **at least 35 s**.\n- `options.*` are upper-bounded by edge (`max_logs_scanned` ≤ 50 000, `max_patterns` ≤ 50, `examples_per_pattern` ≤ 3, `step_seconds` ∈ [15, 300], `max_series` ≤ 200, `topk` ≤ 50, `timeout_seconds` ≤ 30).\n- Two error layers as with `/monit/query/rows`: edge-level execution errors come back as HTTP 200 with an `error` object in the body — check both layers.\n- Log examples are basic-redacted before being returned; expect `warnings: [\"examples redacted\"]`. Do not treat them as raw logs.", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **600 requests/minute**; **10 requests/second** per account |\n| Permissions | Any valid `app_key` (read-only; not gated by a specific permission class) |\n\n## Usage\n\n- This is a diagnostic / RCA endpoint, not a raw data query — pair it with `/monit/query/data` when you need detailed rows.\n- Only three `ds_type` and `operation` pairs are supported: `loki` / `victorialogs` → `log_patterns`, and `prometheus` → `metric_trends`. Every other datasource is rejected, even when `operation` is explicit.\n- `methods` selects the analyses to run; when omitted, `log_patterns` defaults to `pattern_snapshot + pattern_compare(previous_window)` and `metric_trends` defaults to `single_window_shape + window_compare(previous_window)`.\n- `time_range` is in Unix seconds; missing or invalid values default to the last 15 minutes; a window wider than 6 hours is rejected.\n- The request is forwarded over WebSocket to `monit-edge`. Long-running: the request may take up to ~30 s on the edge side plus webapi overhead. Set client timeouts to **at least 35 s**.\n- `options.*` are upper-bounded by edge (`max_logs_scanned` ≤ 50 000, `max_patterns` ≤ 50, `examples_per_pattern` ≤ 3, `step_seconds` ∈ [15, 300], `max_series` ≤ 200, `topk` ≤ 50, `timeout_seconds` ≤ 30).\n- Two error layers exist: edge-level execution errors come back as HTTP 200 with an `error` object in the body — check both layers.\n- Log examples are basic-redacted before being returned; expect `warnings: [\"examples redacted\"]`. Do not treat them as raw logs.", "href": "/en/api-reference/monitors/diagnostics/monit-read-query-diagnose", "metadata": { "sidebarTitle": "Diagnose data source" @@ -22185,85 +22018,6 @@ ] } }, - "/monit/preview/sync": { - "post": { - "operationId": "monit-preview-sync", - "summary": "Preview datasource query", - "description": "Execute a synchronous datasource query and return the raw result. Used to preview alert rule expressions before saving.", - "tags": [ - "Monitors/Monitor utilities" - ], - "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **60 requests/minute**; **10 requests/second** per account |\n| Permissions | None — any valid `app_key` can call this operation |\n\n## Usage\n\n- `ds_type` must match the datasource type (e.g. `prometheus`, `loki`).\n- `ds_name` is the display name of the datasource as configured in the account.\n- `delay_seconds` shifts the query window backward by the specified number of seconds, useful for accommodating data ingestion latency.\n- The response body is the raw JSON returned by the datasource — its schema varies by datasource type.", - "href": "/en/api-reference/monitors/monitor-utilities/monit-preview-sync", - "metadata": { - "sidebarTitle": "Preview datasource query" - } - }, - "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/PreviewSyncResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "status": "success", - "data": { - "resultType": "vector", - "result": [] - } - } - } - } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PreviewSyncRequest" - }, - "example": { - "ds_type": "prometheus", - "ds_name": "Prometheus Prod", - "expr": "rate(http_requests_total[5m])", - "delay_seconds": 0 - } - } - } - } - } - }, "/status-page/info": { "get": { "operationId": "statusPageInfo", @@ -43600,16 +43354,6 @@ "description": "Empty response on success.", "additionalProperties": false }, - "RuleFolderIDRequest": { - "type": "object", - "properties": { - "folder_id": { - "type": "integer", - "format": "uint64", - "description": "Folder ID to summarize. Obtainable via `POST /monit/folder/list`. Trigger statistics are returned grouped by direct child folder." - } - } - }, "RuleFieldsUpdateRequest": { "type": "object", "required": [ @@ -47893,12 +47637,44 @@ } }, "QueryDataRequest": { - "description": "Request for the stable structured query endpoint. It uses the same query fields as the deprecated rows endpoint.", - "allOf": [ - { - "$ref": "#/components/schemas/QueryRowsRequest" + "type": "object", + "required": [ + "ds_type", + "ds_name", + "expr" + ], + "properties": { + "account_id": { + "type": "integer", + "format": "int64", + "description": "Optional consistency check. Must equal the authenticated account when supplied; mismatched values are rejected. Business execution always uses the authenticated account." + }, + "ds_type": { + "type": "string", + "description": "Data source type; must match a configured data source under the tenant. Examples: `prometheus`, `loki`, `victorialogs`, `sls`, `elasticsearch`, `mysql`, `postgres`, `oracle`, `clickhouse`." + }, + "ds_name": { + "type": "string", + "description": "Data source name; must match a configured data source under the tenant." + }, + "expr": { + "type": "string", + "description": "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.)." + }, + "delay_seconds": { + "type": "integer", + "description": "Look-back offset in seconds applied to point-in-time queries (Prometheus, Loki stats, VictoriaLogs stats). Ignored for raw / detail queries.", + "default": 0 + }, + "args": { + "type": "object", + "description": "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.", + "additionalProperties": { + "type": "string" + } } - ] + }, + "description": "Request for the stable structured query endpoint." }, "QueryDataResponse": { "type": "object", @@ -48124,72 +47900,6 @@ } } }, - "QueryRowsRequest": { - "type": "object", - "required": [ - "ds_type", - "ds_name", - "expr" - ], - "properties": { - "account_id": { - "type": "integer", - "format": "int64", - "description": "Optional consistency check. Must equal the authenticated account when supplied; mismatched values are rejected. Business execution always uses the authenticated account." - }, - "ds_type": { - "type": "string", - "description": "Data source type; must match a configured data source under the tenant. Examples: `prometheus`, `loki`, `victorialogs`, `sls`, `elasticsearch`, `mysql`, `postgres`, `oracle`, `clickhouse`." - }, - "ds_name": { - "type": "string", - "description": "Data source name; must match a configured data source under the tenant." - }, - "expr": { - "type": "string", - "description": "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.)." - }, - "delay_seconds": { - "type": "integer", - "description": "Look-back offset in seconds applied to point-in-time queries (Prometheus, Loki stats, VictoriaLogs stats). Ignored for raw / detail queries.", - "default": 0 - }, - "args": { - "type": "object", - "description": "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.", - "additionalProperties": { - "type": "string" - } - } - } - }, - "QueryRowsResponse": { - "type": "array", - "description": "Result rows. Different data sources populate `fields` vs `values` differently — metric sources (Prometheus, *-stats) put numbers into `values`; detail sources (SQL, SLS, raw logs) put data into `fields` and may return `values: null`.", - "items": { - "$ref": "#/components/schemas/QueryRow" - } - }, - "QueryRow": { - "type": "object", - "properties": { - "fields": { - "type": "object", - "description": "String-valued fields (labels, log fields, SQL columns).", - "additionalProperties": { - "type": "string" - } - }, - "values": { - "type": "object", - "nullable": true, - "description": "Numeric fields. For metric queries the canonical key is `__value__`. May be `null` for detail-oriented sources.", - "additionalProperties": { - "type": "number" - } - } - } - }, "DiagnoseRequest": { "type": "object", "required": [ @@ -49581,44 +49291,6 @@ } } }, - "PreviewSyncRequest": { - "type": "object", - "required": [ - "ds_type", - "ds_name", - "expr" - ], - "description": "Parameters for a synchronous datasource query preview.", - "properties": { - "ds_type": { - "type": "string", - "description": "Datasource type, e.g. `prometheus`, `loki`, `elasticsearch`." - }, - "ds_name": { - "type": "string", - "description": "Datasource display name as configured in the account." - }, - "expr": { - "type": "string", - "description": "Query expression. Format depends on `ds_type` (PromQL for Prometheus, LogQL for Loki, etc.)." - }, - "delay_seconds": { - "type": "integer", - "description": "Shift the query window backward by this many seconds to compensate for data ingestion latency." - }, - "args": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "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." - } - } - }, - "PreviewSyncResponse": { - "type": "object", - "description": "Raw JSON response from the datasource. Schema varies by datasource type." - }, "ResetPostMortemBasicsRequest": { "type": "object", "description": "Basic incident facts to write back to a post-mortem report.", diff --git a/openapi/openapi.zh.json b/openapi/openapi.zh.json index 3948a5e..d16707a 100644 --- a/openapi/openapi.zh.json +++ b/openapi/openapi.zh.json @@ -121,10 +121,6 @@ "name": "AI SRE/会话", "description": "AI SRE 智能体会话历史 —— 查询、查看与导出会话记录。" }, - { - "name": "Monitors/通用工具", - "description": "监控服务开通及数据预览工具。" - }, { "name": "AI SRE/自动化" }, @@ -14130,83 +14126,6 @@ } } }, - "/monit/rule/status": { - "post": { - "operationId": "monit-rule-write-status", - "summary": "查看文件夹下规则触发状态", - "description": "返回指定文件夹节点及其子孙节点下所有规则的触发情况汇总。", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 将 `folder_id` 设为 `0` 可获取所有文件夹的汇总。\n- 若文件夹包含规则数量过多,为保护系统会跳过计算。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-status", - "metadata": { - "sidebarTitle": "查看文件夹下规则触发状态" - } - }, - "responses": { - "200": { - "description": "成功", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/RuleStatusResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "folder_id": 100, - "folder_name": "生产环境", - "rule_total": 10, - "triggered_rule_count": 2 - } - ] - } - } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/RuleFolderIDRequest" - }, - "example": { - "folder_id": 100 - } - } - } - } - } - }, "/monit/rule/audits": { "post": { "operationId": "monit-rule-read-audits", @@ -19888,7 +19807,7 @@ "Monitors/诊断分析" ], "x-mint": { - "content": "## 调用限制\n\n| 项 | 值 |\n| ------ | ----- |\n| 速率限制 | 每账户 **100 次/分钟**、**5 次/秒** |\n| 权限 | 任意有效的 `app_key`(只读,不受特定权限分类限制) |\n| Edge 版本要求 | 受支持的部署要求 **monit-edge v0.65.0 或更高版本** |\n\n## 使用说明\n\n- 此公开接口以 **monit-edge v0.65.0** 为最低受支持版本。迁移期间,WebAPI 仍保留旧版 Edge 适配器:query.v2 结果仍可能保留 frames、records 或 samples,而 legacy rows 只能提供其已保留的信息。这些适配器不会改变最低支持版本;旧协议缺少 query.v3 的取消和错误生命周期语义,legacy rows 已丢失的数据也无法恢复。\n- 公开响应格式固定为 `query_result.v1`,与 Edge 内部查询协议版本无关。必须根据 `result.kind`(`frames`、`records` 或 `samples`)分发结果,不要根据 `ds_type` 或 Edge 版本猜测结果形态。\n- `frames` 结果可以包含多个表格或时序 Frame。字段值按列组织,同一 Frame 中所有字段的值数量一致。\n- `records` 结果可以包含嵌套 JSON 和 null record。超出 JavaScript 安全整数范围的整数字面量会以十进制字符串返回。\n- `samples` 结果包含标签集合和瞬时值。值可以是数字,也可以是字符串 `NaN`、`+Inf` 或 `-Inf`。\n- 最终成功响应上限为 8 MiB,查询结果上限为 1,000 行。超限时请缩短时间范围、减少字段或在数据源侧聚合。\n- 查询失败使用非 2xx HTTP 状态码和标准错误 envelope。不要透明回退到已弃用的 `/monit/query/rows` 接口。\n- WebAPI 跨实例转发和 Edge 执行合计可能耗时 35 秒。客户端超时建议至少设为 40 秒,并在调用方放弃查询时向下传播取消信号。", + "content": "## 调用限制\n\n| 项 | 值 |\n| ------ | ----- |\n| 速率限制 | 每账户 **100 次/分钟**、**5 次/秒** |\n| 权限 | 任意有效的 `app_key`(只读,不受特定权限分类限制) |\n| Edge 版本要求 | 受支持的部署要求 **monit-edge v0.65.0 或更高版本** |\n\n## 使用说明\n\n- 此公开接口以 **monit-edge v0.65.0** 为最低受支持版本。迁移期间,WebAPI 仍保留旧版 Edge 适配器:query.v2 结果仍可能保留 frames、records 或 samples,而 legacy rows 只能提供其已保留的信息。这些适配器不会改变最低支持版本;旧协议缺少 query.v3 的取消和错误生命周期语义,legacy rows 已丢失的数据也无法恢复。\n- 公开响应格式固定为 `query_result.v1`,与 Edge 内部查询协议版本无关。必须根据 `result.kind`(`frames`、`records` 或 `samples`)分发结果,不要根据 `ds_type` 或 Edge 版本猜测结果形态。\n- `frames` 结果可以包含多个表格或时序 Frame。字段值按列组织,同一 Frame 中所有字段的值数量一致。\n- `records` 结果可以包含嵌套 JSON 和 null record。超出 JavaScript 安全整数范围的整数字面量会以十进制字符串返回。\n- `samples` 结果包含标签集合和瞬时值。值可以是数字,也可以是字符串 `NaN`、`+Inf` 或 `-Inf`。\n- 最终成功响应上限为 8 MiB,查询结果上限为 1,000 行。超限时请缩短时间范围、减少字段或在数据源侧聚合。\n- 查询失败使用非 2xx HTTP 状态码和标准错误 envelope。旧版 `/monit/query/rows` 接口已下线;数据源查询请使用此接口。\n- WebAPI 跨实例转发和 Edge 执行合计可能耗时 35 秒。客户端超时建议至少设为 40 秒,并在调用方放弃查询时向下传播取消信号。", "href": "/zh/api-reference/monitors/diagnostics/monit-read-query-data", "metadata": { "sidebarTitle": "查询结构化数据" @@ -20002,92 +19921,6 @@ } } }, - "/monit/query/rows": { - "post": { - "operationId": "monit-read-query-rows", - "summary": "查询数据源原始行", - "description": "已弃用。执行同步即席查询并返回历史扁平 rows 结构。现有调用方应迁移到 `/monit/query/data`;新接口会保留 frames、records 和 samples 的自然语义,不再把所有结果强制压成 legacy rows。", - "deprecated": true, - "tags": [ - "Monitors/诊断分析" - ], - "x-mint": { - "content": "## 已弃用\n\n所有新集成请使用 [`POST /monit/query/data`](/zh/api-reference/monitors/diagnostics/monit-read-query-data)。本接口仅在现有前端和 AI SRE 调用方迁移期间保留。\n\n## 调用限制\n\n| 项 | 值 |\n| ------ | ----- |\n| 速率限制 | 每账户 **100 次/分钟**、**5 次/秒** |\n| 权限 | 任意有效的 `app_key`(只读,不受特定权限分类限制) |\n\n## 使用说明\n\n- 请求通过 WebSocket 转发至 `monit-edge`;`ds_type` + `ds_name` 指定的数据源必须已存在于调用账户下。\n- 请求体中的 `account_id` 可选。若传入,必须与认证账户一致;不一致将被拒绝。\n- 参数校验失败使用标准错误 envelope。当 `monit-edge` 拒绝查询时,其 `{\"error\": {\"code\": ..., \"message\": ...}}` 响应体会被保留,HTTP 状态码与 Edge 错误码一致;错误码无效或缺失时返回 HTTP 500。请同时检查状态码和错误响应体。\n- monit-edge 强制行数上限;结果过多时返回 `error.message = \"too many rows\"`。请缩小时间范围或在数据源侧聚合。\n- `args` 是透传的多态 `string→string` 映射,语义取决于 `ds_type`(SLS 需要 `sls.project` + `sls.logstore`;Loki/VictoriaLogs 原始模式需要通过 `*.start`/`*.end` 或 `*.timespan.value`/`*.timespan.unit` 指定时间范围;Prometheus 和 SQL 数据源忽略该字段)。各数据源完整参数列表见 monit-webapi query-api 文档。", - "href": "/zh/api-reference/monitors/diagnostics/monit-read-query-rows", - "metadata": { - "sidebarTitle": "查询数据源原始行" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/QueryRowsRequest" - }, - "example": { - "account_id": 10001, - "ds_type": "prometheus", - "ds_name": "prod-prom", - "expr": "up", - "delay_seconds": 30 - } - } - } - }, - "responses": { - "200": { - "description": "成功", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/QueryRowsResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "fields": { - "__name__": "up", - "instance": "10.0.0.1:9100", - "job": "node" - }, - "values": { - "__value__": 1 - } - } - ] - } - } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - } - } - }, "/monit/query/diagnose": { "post": { "operationId": "monit-read-query-diagnose", @@ -20097,7 +19930,7 @@ "Monitors/诊断分析" ], "x-mint": { - "content": "## 调用限制\n\n| 项 | 值 |\n| ------ | ----- |\n| 速率限制 | **600 次/分钟**;**10 次/秒** 每账户 |\n| 权限 | 任意有效的 `app_key`(只读;不受特定权限分类约束) |\n\n## 使用说明\n\n- 这是诊断 / RCA 接口,而非原始数据查询接口——如需查看明细行,请配合 `/monit/query/rows` 使用。\n- 仅支持三种 `ds_type` 与 `operation` 组合:`loki` / `victorialogs` → `log_patterns`,`prometheus` → `metric_trends`。即使显式传入 `operation`,其他数据源也会被拒绝。\n- `methods` 选择要执行的分析方法;省略时,`log_patterns` 默认为 `pattern_snapshot + pattern_compare(previous_window)`,`metric_trends` 默认为 `single_window_shape + window_compare(previous_window)`。\n- `time_range` 单位为 Unix 秒;缺失或无效时默认最近 15 分钟;窗口宽度超过 6 小时将被拒绝。\n- 请求通过 WebSocket 转发至 `monit-edge`。长耗时:边缘侧执行可能耗时约 30 秒,叠加 webapi 开销。客户端超时应至少设置为 **35 秒**。\n- `options.*` 由边缘侧设置上限(`max_logs_scanned` ≤ 50 000,`max_patterns` ≤ 50,`examples_per_pattern` ≤ 3,`step_seconds` ∈ [15, 300],`max_series` ≤ 200,`topk` ≤ 50,`timeout_seconds` ≤ 30)。\n- 与 `/monit/query/rows` 一样存在两层错误:边缘侧执行错误以 HTTP 200 返回,响应体中带 `error` 对象——务必同时检查两层。\n- 日志样例在返回前会经过基础脱敏处理,响应中会带 `warnings: [\"examples redacted\"]`。不可作为原始日志使用。", + "content": "## 调用限制\n\n| 项 | 值 |\n| ------ | ----- |\n| 速率限制 | **600 次/分钟**;**10 次/秒** 每账户 |\n| 权限 | 任意有效的 `app_key`(只读;不受特定权限分类约束) |\n\n## 使用说明\n\n- 这是诊断 / RCA 接口,而非原始数据查询接口——如需查看明细行,请配合 `/monit/query/data` 使用。\n- 仅支持三种 `ds_type` 与 `operation` 组合:`loki` / `victorialogs` → `log_patterns`,`prometheus` → `metric_trends`。即使显式传入 `operation`,其他数据源也会被拒绝。\n- `methods` 选择要执行的分析方法;省略时,`log_patterns` 默认为 `pattern_snapshot + pattern_compare(previous_window)`,`metric_trends` 默认为 `single_window_shape + window_compare(previous_window)`。\n- `time_range` 单位为 Unix 秒;缺失或无效时默认最近 15 分钟;窗口宽度超过 6 小时将被拒绝。\n- 请求通过 WebSocket 转发至 `monit-edge`。长耗时:边缘侧执行可能耗时约 30 秒,叠加 webapi 开销。客户端超时应至少设置为 **35 秒**。\n- `options.*` 由边缘侧设置上限(`max_logs_scanned` ≤ 50 000,`max_patterns` ≤ 50,`examples_per_pattern` ≤ 3,`step_seconds` ∈ [15, 300],`max_series` ≤ 200,`topk` ≤ 50,`timeout_seconds` ≤ 30)。\n- 此接口存在两层错误:边缘侧执行错误以 HTTP 200 返回,响应体中带 `error` 对象——务必同时检查两层。\n- 日志样例在返回前会经过基础脱敏处理,响应中会带 `warnings: [\"examples redacted\"]`。不可作为原始日志使用。", "href": "/zh/api-reference/monitors/diagnostics/monit-read-query-diagnose", "metadata": { "sidebarTitle": "数据源诊断" @@ -22177,85 +22010,6 @@ ] } }, - "/monit/preview/sync": { - "post": { - "operationId": "monit-preview-sync", - "summary": "同步预览数据源查询", - "description": "同步执行数据源查询并返回原始结果,用于在保存前预览告警规则表达式的效果。", - "tags": [ - "Monitors/通用工具" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **60 次/分钟**;**10 次/秒** |\n| 权限要求 | 无 —— 持有有效的 `app_key` 即可调用 |\n\n## 使用说明\n\n- `ds_type` 须与数据源类型匹配,如 `prometheus`、`loki`。\n- `ds_name` 为账户中配置的数据源显示名称。\n- `delay_seconds` 将查询窗口向前偏移指定秒数,用于补偿数据摄入延迟。\n- 响应体为数据源返回的原始 JSON,其结构随数据源类型而异。", - "href": "/zh/api-reference/monitors/monitor-utilities/monit-preview-sync", - "metadata": { - "sidebarTitle": "同步预览数据源查询" - } - }, - "responses": { - "200": { - "description": "成功", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/PreviewSyncResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "status": "success", - "data": { - "resultType": "vector", - "result": [] - } - } - } - } - } - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PreviewSyncRequest" - }, - "example": { - "ds_type": "prometheus", - "ds_name": "生产 Prometheus", - "expr": "rate(http_requests_total[5m])", - "delay_seconds": 0 - } - } - } - } - } - }, "/status-page/info": { "get": { "operationId": "statusPageInfo", @@ -43591,16 +43345,6 @@ "description": "成功时返回空对象。", "additionalProperties": false }, - "RuleFolderIDRequest": { - "type": "object", - "properties": { - "folder_id": { - "type": "integer", - "format": "uint64", - "description": "要统计的文件夹 ID,可通过 `POST /monit/folder/list` 获取。服务端按直属子文件夹分组返回规则触发统计。" - } - } - }, "RuleFieldsUpdateRequest": { "type": "object", "required": [ @@ -47884,12 +47628,44 @@ } }, "QueryDataRequest": { - "description": "稳定结构化查询接口的请求。字段与已弃用的 rows 接口一致。", - "allOf": [ - { - "$ref": "#/components/schemas/QueryRowsRequest" + "type": "object", + "required": [ + "ds_type", + "ds_name", + "expr" + ], + "properties": { + "account_id": { + "type": "integer", + "format": "int64", + "description": "可选的一致性校验。若提供,必须等于已认证账户;不一致将被拒绝。业务执行始终使用已认证账户。" + }, + "ds_type": { + "type": "string", + "description": "数据源类型;必须匹配租户下已配置的数据源。示例:`prometheus`、`loki`、`victorialogs`、`sls`、`elasticsearch`、`mysql`、`postgres`、`oracle`、`clickhouse`。" + }, + "ds_name": { + "type": "string", + "description": "数据源名称;必须匹配租户下已配置的数据源。" + }, + "expr": { + "type": "string", + "description": "查询表达式。语法取决于 `ds_type`,由对应的 monit-edge 客户端解释(Prometheus 用 PromQL,Loki 用 LogQL,SQL 类数据源用 SQL,等等)。" + }, + "delay_seconds": { + "type": "integer", + "description": "应用于点查询(Prometheus、Loki stats、VictoriaLogs stats)的回看偏移,单位秒。明细 / raw 查询忽略该字段。", + "default": 0 + }, + "args": { + "type": "object", + "description": "透传给 monit-edge 的多态键值扩展参数。所有值必须是字符串,键一律按数据源加前缀(如 `sls.project`、`loki.type`)。校验规则取决于 `ds_type`:SLS 必须提供 `sls.project` 与 `sls.logstore`;Elasticsearch 的 `es.type` 只接受 `sql` 或不传,其他值一律拒绝;Loki 与 VictoriaLogs 的 `.type` 接受 `stats`、`raw` 或不传,其中 `raw` 还必须给出时间范围——`.start` + `.end`,或 `.timespan.value` + `.timespan.unit`(单位取 `s`/`m`/`h`/`d`)。Prometheus 及其余 SQL 类数据源完全忽略 `args`。", + "additionalProperties": { + "type": "string" + } } - ] + }, + "description": "稳定结构化查询接口的请求参数。" }, "QueryDataResponse": { "type": "object", @@ -48115,72 +47891,6 @@ } } }, - "QueryRowsRequest": { - "type": "object", - "required": [ - "ds_type", - "ds_name", - "expr" - ], - "properties": { - "account_id": { - "type": "integer", - "format": "int64", - "description": "可选的一致性校验。若提供,必须等于已认证账户;不一致将被拒绝。业务执行始终使用已认证账户。" - }, - "ds_type": { - "type": "string", - "description": "数据源类型;必须匹配租户下已配置的数据源。示例:`prometheus`、`loki`、`victorialogs`、`sls`、`elasticsearch`、`mysql`、`postgres`、`oracle`、`clickhouse`。" - }, - "ds_name": { - "type": "string", - "description": "数据源名称;必须匹配租户下已配置的数据源。" - }, - "expr": { - "type": "string", - "description": "查询表达式。语法取决于 `ds_type`,由对应的 monit-edge 客户端解释(Prometheus 用 PromQL,Loki 用 LogQL,SQL 类数据源用 SQL,等等)。" - }, - "delay_seconds": { - "type": "integer", - "description": "应用于点查询(Prometheus、Loki stats、VictoriaLogs stats)的回看偏移,单位秒。明细 / raw 查询忽略该字段。", - "default": 0 - }, - "args": { - "type": "object", - "description": "透传给 monit-edge 的多态键值扩展参数。所有值必须是字符串,键一律按数据源加前缀(如 `sls.project`、`loki.type`)。校验规则取决于 `ds_type`:SLS 必须提供 `sls.project` 与 `sls.logstore`;Elasticsearch 的 `es.type` 只接受 `sql` 或不传,其他值一律拒绝;Loki 与 VictoriaLogs 的 `.type` 接受 `stats`、`raw` 或不传,其中 `raw` 还必须给出时间范围——`.start` + `.end`,或 `.timespan.value` + `.timespan.unit`(单位取 `s`/`m`/`h`/`d`)。Prometheus 及其余 SQL 类数据源完全忽略 `args`。", - "additionalProperties": { - "type": "string" - } - } - } - }, - "QueryRowsResponse": { - "type": "array", - "description": "结果行。不同数据源对 `fields` 与 `values` 的填充方式不同——指标类数据源(Prometheus、*-stats)将数字放入 `values`;明细类数据源(SQL、SLS、原始日志)将数据放入 `fields`,`values` 可能为 `null`。", - "items": { - "$ref": "#/components/schemas/QueryRow" - } - }, - "QueryRow": { - "type": "object", - "properties": { - "fields": { - "type": "object", - "description": "字符串值字段(标签、日志字段、SQL 列)。", - "additionalProperties": { - "type": "string" - } - }, - "values": { - "type": "object", - "nullable": true, - "description": "数值字段。对于指标查询,规范键名为 `__value__`。对于明细类数据源可能为 `null`。", - "additionalProperties": { - "type": "number" - } - } - } - }, "DiagnoseRequest": { "type": "object", "required": [ @@ -49572,44 +49282,6 @@ } } }, - "PreviewSyncRequest": { - "type": "object", - "required": [ - "ds_type", - "ds_name", - "expr" - ], - "description": "同步数据源查询预览的参数。", - "properties": { - "ds_type": { - "type": "string", - "description": "数据源类型,如 `prometheus`、`loki`、`elasticsearch`。" - }, - "ds_name": { - "type": "string", - "description": "账户中配置的数据源显示名称。" - }, - "expr": { - "type": "string", - "description": "查询表达式,格式因 `ds_type` 而异(Prometheus 为 PromQL,Loki 为 LogQL 等)。" - }, - "delay_seconds": { - "type": "integer", - "description": "将查询窗口向前偏移的秒数,用于补偿数据摄入延迟。" - }, - "args": { - "type": "object", - "additionalProperties": { - "type": "string" - }, - "description": "特定数据源类型的附加查询参数(键值均为字符串),如 SLS 的 `sls.project`、`sls.logstore`,Elasticsearch 的 `es.type`,Loki 的 `loki.type`、`loki.limit`。" - } - } - }, - "PreviewSyncResponse": { - "type": "object", - "description": "数据源返回的原始 JSON,结构随数据源类型而异。" - }, "ResetPostMortemBasicsRequest": { "type": "object", "description": "写回复盘报告的故障基础信息。", diff --git a/roundtrip_gen_test.go b/roundtrip_gen_test.go index ea4f060..5d371ba 100644 --- a/roundtrip_gen_test.go +++ b/roundtrip_gen_test.go @@ -109,7 +109,6 @@ var exampleDataDecoders = map[string]func(json.RawMessage) error{ "POST /monit/datasource/update": func(d json.RawMessage) error { var v DataSourceItem; return json.Unmarshal(d, &v) }, "POST /monit/query/data": func(d json.RawMessage) error { var v QueryDataResponse; return json.Unmarshal(d, &v) }, "POST /monit/query/diagnose": func(d json.RawMessage) error { var v DiagnoseResponse; return json.Unmarshal(d, &v) }, - "POST /monit/query/rows": func(d json.RawMessage) error { var v QueryRowsResponse; return json.Unmarshal(d, &v) }, "POST /monit/rule/audit/detail": func(d json.RawMessage) error { var v AlertRuleAudit; return json.Unmarshal(d, &v) }, "POST /monit/rule/audits": func(d json.RawMessage) error { var v RuleAuditListResponse; return json.Unmarshal(d, &v) }, "POST /monit/rule/counter/channel": func(d json.RawMessage) error { var v RuleCounterChannelResponse; return json.Unmarshal(d, &v) }, @@ -123,7 +122,6 @@ var exampleDataDecoders = map[string]func(json.RawMessage) error{ "POST /monit/rule/info": func(d json.RawMessage) error { var v AlertRuleInfoResponse; return json.Unmarshal(d, &v) }, "POST /monit/rule/list/basic": func(d json.RawMessage) error { var v RuleBasicListResponse; return json.Unmarshal(d, &v) }, "POST /monit/rule/move": func(d json.RawMessage) error { var v RuleNameMessageListResponse; return json.Unmarshal(d, &v) }, - "POST /monit/rule/status": func(d json.RawMessage) error { var v RuleStatusResponse; return json.Unmarshal(d, &v) }, "POST /monit/rule/update": func(d json.RawMessage) error { var v AlertRule; return json.Unmarshal(d, &v) }, "POST /monit/rule/update/fields": func(d json.RawMessage) error { var v RuleNameMessageListResponse; return json.Unmarshal(d, &v) }, "POST /monit/servicemap/fleet": func(d json.RawMessage) error { var v ServiceMapFleetBrowseResponse; return json.Unmarshal(d, &v) }, diff --git a/services_gen.go b/services_gen.go index 55b85f4..b853af6 100644 --- a/services_gen.go +++ b/services_gen.go @@ -17,7 +17,6 @@ type genServices struct { AlertRules *AlertRulesService DataSources *DataSourcesService Diagnostics *DiagnosticsService - MonitorUtilities *MonitorUtilitiesService RuleSets *RuleSetsService ServiceMap *ServiceMapService AlertEnrichment *AlertEnrichmentService @@ -61,7 +60,6 @@ func (c *Client) initServices() { c.AlertRules = (*AlertRulesService)(&c.common) c.DataSources = (*DataSourcesService)(&c.common) c.Diagnostics = (*DiagnosticsService)(&c.common) - c.MonitorUtilities = (*MonitorUtilitiesService)(&c.common) c.RuleSets = (*RuleSetsService)(&c.common) c.ServiceMap = (*ServiceMapService)(&c.common) c.AlertEnrichment = (*AlertEnrichmentService)(&c.common)