From e3bc1effc92d17cfdf7ba3a75a051ea6676156e5 Mon Sep 17 00:00:00 2001 From: Ulric Qin Date: Wed, 9 Sep 2026 19:35:34 +0800 Subject: [PATCH] docs(monit): retire v1 alert rule endpoints, document public v2 contract - Remove /monit/rule/info, /monit/rule/create, /monit/rule/update, /monit/rule/counter/node (retired in monit-webapi) and /monit/rule/dstypes (route and registry row no longer exist) from the monitors module spec and the consolidated reference copies. - Add /monit/rule/v2/info, /monit/rule/v2/create, /monit/rule/v2/update with full bilingual operations and AlertRuleV2 schemas extracted from the monit-webapi Go types, including lifecycle v2 enums, rate limits, permission classes and request/response examples. - Reconcile docs.json pages and the zh/en API catalog tables; drop orphaned schemas (AlertRuleInfoResponse, RuleCounterNodeResponse, RuleDsTypesResponse, DSType) and dangling references to the deleted dstypes endpoint. Validated with scripts/lint_openapi.py (12 spec files, no violations). --- api-reference/monitors.openapi.en.json | 1421 +++++++++++++++-------- api-reference/monitors.openapi.zh.json | 1421 +++++++++++++++-------- api-reference/openapi.en.json | 1479 ++++++++++++++++-------- api-reference/openapi.zh.json | 1479 ++++++++++++++++-------- docs.json | 16 +- en/openapi/api-catalog.mdx | 8 +- zh/openapi/api-catalog.mdx | 8 +- 7 files changed, 3862 insertions(+), 1970 deletions(-) diff --git a/api-reference/monitors.openapi.en.json b/api-reference/monitors.openapi.en.json index ca9a4c39..6b08e45e 100644 --- a/api-reference/monitors.openapi.en.json +++ b/api-reference/monitors.openapi.en.json @@ -364,77 +364,6 @@ } } }, - "/monit/rule/counter/node": { - "post": { - "operationId": "monit-rule-read-counter-node", - "summary": "Get rule counts by folder node", - "description": "Return an object mapping top-level folder name to the total number of rules under that folder and all 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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-node", - "metadata": { - "sidebarTitle": "Get rule counts by folder node" - } - }, - "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/RuleCounterNodeResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "Production": 10, - "Staging": 3 - } - } - } - } - }, - "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/RuleEmptyRequest" - }, - "example": {} - } - } - } - } - }, "/monit/rule/audit/detail": { "post": { "operationId": "monit-rule-read-audit-detail", @@ -1080,19 +1009,19 @@ } } }, - "/monit/rule/info": { + "/monit/rule/delete": { "post": { - "operationId": "monit-rule-read-info", - "summary": "Get alert rule detail", - "description": "Return the full configuration of an alert rule by its ID, including rule queries, thresholds, and notification settings.", + "operationId": "monit-rule-write-delete", + "summary": "Delete alert rule", + "description": "Delete a single alert rule by its ID.", "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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-info", + "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- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete", "metadata": { - "sidebarTitle": "Get alert rule detail" + "sidebarTitle": "Delete alert rule" } }, "responses": { @@ -1109,7 +1038,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRuleInfoResponse" + "$ref": "#/components/schemas/RuleEmptyResponse" } } } @@ -1117,20 +1046,7 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "id": 50001, - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "channel_ids": [ - 20001 - ] - } + "data": {} } } } @@ -1163,19 +1079,19 @@ } } }, - "/monit/rule/delete": { + "/monit/rule/import": { "post": { - "operationId": "monit-rule-write-delete", - "summary": "Delete alert rule", - "description": "Delete a single alert rule by its ID.", + "operationId": "monit-rule-write-import", + "summary": "Import alert rules", + "description": "Import one or more alert rules from a JSON array. Returns the result for each rule, indicating success or failure.", "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- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **20 requests/minute**; **2 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- The request body is a JSON array of rule export objects (compatible with the output of `POST /monit/rule/export`).\n- Each object must include `folder_id`, `ds_type`, and either `ds_list` or `ds_ids`.\n- Some rules may fail (e.g. duplicate name). Check each result for individual status.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-import", "metadata": { - "sidebarTitle": "Delete alert rule" + "sidebarTitle": "Import alert rules" } }, "responses": { @@ -1192,7 +1108,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleEmptyResponse" + "$ref": "#/components/schemas/RuleImportResponse" } } } @@ -1200,7 +1116,12 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": {} + "data": [ + { + "name": "CPU High", + "message": "" + } + ] } } } @@ -1223,29 +1144,46 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleIDRequest" + "$ref": "#/components/schemas/RuleImportRequest" }, - "example": { - "id": 50001 - } + "example": [ + { + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "enabled": true, + "cron_pattern": "0 * * * * *", + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "avg(cpu_usage_idle) < 10" + } + ] + } + } + ] } } } } }, - "/monit/rule/dstypes": { + "/monit/rule/list/basic": { "post": { - "operationId": "monit-rule-read-dstypes", - "summary": "List available datasource types", - "description": "Return the list of datasource types (`DSType` records) that the current account can use when authoring alert rules — combines global types and account-scoped types.", + "operationId": "monit-rule-read-list", + "summary": "List alert rules", + "description": "Return the basic information of all alert rules in a folder. For full rule details, call `POST /monit/rule/v2/info`.", "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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-dstypes", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to list all rules across all folders visible to the current user.\n- The `triggered` field indicates whether the rule has any currently active alerts.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-list", "metadata": { - "sidebarTitle": "List available datasource types" + "sidebarTitle": "List alert rules" } }, "responses": { @@ -1262,7 +1200,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleDsTypesResponse" + "$ref": "#/components/schemas/RuleBasicListResponse" } } } @@ -1272,11 +1210,15 @@ "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", "data": [ { - "id": 1, - "name": "Prometheus", - "ident": "prometheus", - "account_id": 0, - "weight": 100 + "id": 50001, + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "enabled": true, + "triggered": true, + "created_at": 1710000000, + "active_alert_count": 2, + "runtime_state": "normal" } ] } @@ -1301,27 +1243,29 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleEmptyRequest" + "$ref": "#/components/schemas/RuleListRequest" }, - "example": {} + "example": { + "folder_id": 100 + } } } } } }, - "/monit/rule/update": { + "/monit/datasource/list": { "post": { - "operationId": "monit-rule-write-update", - "summary": "Update alert rule", - "description": "Replace the full configuration of an existing alert rule. All fields are overwritten.", + "operationId": "monit-datasource-read-list", + "summary": "List datasources", + "description": "Return all data sources for the current account. Optionally filter by `type_ident`. Supports diagnostic types redis_node, redis_sentinel, mongodb_mongod, mongodb_mongos and kafka; enabled and alerting_enabled are independent.", "tags": [ - "Monitors/Alert rules" + "Monitors/Data sources" ], "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- `id` is required. All other fields follow the same rules as `POST /monit/rule/create`.\n- The name must remain unique within its folder; a duplicate returns `InvalidParameter`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-update", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Datasources Read** (`monit`) |\n\n## Usage\n\n- Omit `type_ident` to return all types.\n- Sensitive credential fields (passwords, keys) are not returned in the list response.\n\nSee the request/response schemas for all supported types and credential handling. Diagnostic-only types cannot enable alerting. On create omitted enabled defaults to true; on update omission preserves the current value. Explicit null for enabled or alerting_enabled is invalid. Diagnostic passwords and Kafka private keys are omitted from responses unless they are environment references; omit these secrets on update to preserve them, or send an empty string to clear. Other datasource credentials may be returned and must be handled as sensitive.", + "href": "/en/api-reference/monitors/data-sources/monit-datasource-read-list", "metadata": { - "sidebarTitle": "Update alert rule" + "sidebarTitle": "List datasources" } }, "responses": { @@ -1338,7 +1282,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/DataSourceListResponse" } } } @@ -1346,10 +1290,21 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "id": 50001, - "updated_at": 1712100000 - } + "data": [ + { + "id": 10, + "account_id": 10023, + "type_ident": "prometheus", + "name": "Prometheus Prod", + "enabled": true, + "note": "Production Prometheus", + "address": "http://prometheus.example.com:9090", + "edge_cluster_name": "default", + "updated_at": 1712000000, + "payload": null, + "alerting_enabled": true + } + ] } } } @@ -1372,45 +1327,29 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/DataSourceListRequest" }, "example": { - "id": 50001, - "folder_id": 100, - "name": "CPU High v2", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "rule_configs": { - "queries": [ - { - "name": "A", - "expr": "avg(cpu_usage_idle) < 5" - } - ] - } + "type": "prometheus" } } } } } }, - "/monit/rule/import": { + "/monit/rule/update/fields": { "post": { - "operationId": "monit-rule-write-import", - "summary": "Import alert rules", - "description": "Import one or more alert rules from a JSON array. Returns the result for each rule, indicating success or failure.", + "operationId": "monit-rule-write-fields-update", + "summary": "Batch update rule fields", + "description": "Update specific fields across multiple alert rules at once. Only the fields listed in `fields` are applied.", "tags": [ "Monitors/Alert rules" ], "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **20 requests/minute**; **2 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- The request body is a JSON array of rule export objects (compatible with the output of `POST /monit/rule/export`).\n- Each object must include `folder_id`, `ds_type`, and either `ds_list` or `ds_ids`.\n- Some rules may fail (e.g. duplicate name). Check each result for individual status.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-import", + "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- Include the field names you want to update in the `fields` array, e.g. `[\"enabled\", \"channel_ids\"]`.\n- Only the specified fields are updated; others are left unchanged.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-fields-update", "metadata": { - "sidebarTitle": "Import alert rules" + "sidebarTitle": "Batch update rule fields" } }, "responses": { @@ -1427,7 +1366,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleImportResponse" + "$ref": "#/components/schemas/RuleNameMessageListResponse" } } } @@ -1439,6 +1378,10 @@ { "name": "CPU High", "message": "" + }, + { + "name": "Disk High", + "message": "" } ] } @@ -1463,46 +1406,36 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleImportRequest" + "$ref": "#/components/schemas/RuleFieldsUpdateRequest" }, - "example": [ - { - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "rule_configs": { - "queries": [ - { - "name": "A", - "expr": "avg(cpu_usage_idle) < 10" - } - ] - } - } - ] + "example": { + "ids": [ + 50001, + 50002 + ], + "fields": [ + "enabled" + ], + "enabled": false + } } } } } }, - "/monit/rule/create": { + "/monit/rule/counter/channel": { "post": { - "operationId": "monit-rule-write-create", - "summary": "Create alert rule", - "description": "Create a new alert rule. Returns the created rule with its assigned ID.", - "tags": [ + "operationId": "monit-rule-read-counter-channel", + "summary": "Get rule counts by channel", + "description": "Return an object mapping channel name to the number of rules routing alerts to that channel. If a channel name cannot be resolved, the channel ID (as a string) is used as the key.", + "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- `name`, `ds_type`, `cron_pattern`, and `rule_configs.queries` are required.\n- Either `ds_list` (supports wildcards) or `ds_ids` must be non-empty.\n- `cron_pattern` uses standard 5-field cron syntax.\n- `channel_ids` can be empty; alerts will then route through the global integration.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-create", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-channel", "metadata": { - "sidebarTitle": "Create alert rule" + "sidebarTitle": "Get rule counts by channel" } }, "responses": { @@ -1519,7 +1452,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleCounterChannelResponse" } } } @@ -1528,11 +1461,7 @@ "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", "data": { - "id": 50001, - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "created_at": 1712000000 + "Production": 8 } } } @@ -1556,57 +1485,27 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleEmptyRequest" }, - "example": { - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "channel_ids": [ - 20001 - ], - "rule_configs": { - "queries": [ - { - "name": "A", - "expr": "avg(cpu_usage_idle) < 10" - } - ], - "check_threshold": { - "enabled": true, - "critical": "A", - "alerting_check_times": 1, - "recovery_check_times": 1, - "push_recovery_event": true, - "recovery": { - "mode": "invert" - } - } - } - } + "example": {} } } } } }, - "/monit/rule/list/basic": { + "/monit/rule/v2/info": { "post": { - "operationId": "monit-rule-read-list", - "summary": "List alert rules", - "description": "Return the basic information of all alert rules in a folder. For full rule details, call `POST /monit/rule/info`.", + "operationId": "monit-rule-read-info-v2", + "summary": "Get alert rule detail (V2)", + "description": "Return the full V2 configuration of an alert rule by ID, including lifecycle v2 recovery and ending modes.", "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 Read** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to list all rules across all folders visible to the current user.\n- The `triggered` field indicates whether the rule has any currently active alerts.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-list", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |\n\n## Usage\n\n- `id` is required and must not be `0`; otherwise the call returns `InvalidParameter`.\n- A missing rule returns `InvalidParameter` (`alert rule not found`).", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-info-v2", "metadata": { - "sidebarTitle": "List alert rules" + "sidebarTitle": "Get alert rule detail (V2)" } }, "responses": { @@ -1623,7 +1522,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleBasicListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } } } @@ -1631,19 +1530,70 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "id": 50001, - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "enabled": true, - "triggered": true, - "created_at": 1710000000, - "active_alert_count": 2, - "runtime_state": "normal" - } - ] + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } } @@ -1666,29 +1616,29 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleListRequest" + "$ref": "#/components/schemas/RuleIDRequest" }, "example": { - "folder_id": 100 + "id": 50001 } } } } } }, - "/monit/datasource/list": { + "/monit/rule/v2/create": { "post": { - "operationId": "monit-datasource-read-list", - "summary": "List datasources", - "description": "Return all data sources for the current account. Optionally filter by `type_ident`. Supports diagnostic types redis_node, redis_sentinel, mongodb_mongod, mongodb_mongos and kafka; enabled and alerting_enabled are independent.", + "operationId": "monit-rule-write-create-v2", + "summary": "Create alert rule (V2)", + "description": "Create a new V2 alert rule. Returns the created rule with its assigned ID.", "tags": [ - "Monitors/Data sources" + "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 | **Datasources Read** (`monit`) |\n\n## Usage\n\n- Omit `type_ident` to return all types.\n- Sensitive credential fields (passwords, keys) are not returned in the list response.\n\nSee the request/response schemas for all supported types and credential handling. Diagnostic-only types cannot enable alerting. On create omitted enabled defaults to true; on update omission preserves the current value. Explicit null for enabled or alerting_enabled is invalid. Diagnostic passwords and Kafka private keys are omitted from responses unless they are environment references; omit these secrets on update to preserve them, or send an empty string to clear. Other datasource credentials may be returned and must be handled as sensitive.", - "href": "/en/api-reference/monitors/data-sources/monit-datasource-read-list", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **300 requests/minute**; **20 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- `name`, `ds_type`, `enabled`, `cron_pattern`, and `rule_configs.queries` are required; either `ds_list` (supports wildcards) or `ds_ids` must be non-empty.\n- `enabled` must be passed explicitly (including `false`); omitting it returns `InvalidParameter`.\n- `id`, `account_id`, `creator_*`, `updater_*`, `created_at`, and `updated_at` are assigned by the server; client-supplied values are ignored.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- `channel_ids` can be empty; alerts will then route through the global integration.\n- The request body tolerates additional unknown fields (forward compatibility); they are ignored.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-create-v2", "metadata": { - "sidebarTitle": "List datasources" + "sidebarTitle": "Create alert rule (V2)" } }, "responses": { @@ -1705,7 +1655,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/DataSourceListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } } } @@ -1713,21 +1663,70 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "id": 10, - "account_id": 10023, - "type_ident": "prometheus", - "name": "Prometheus Prod", - "enabled": true, - "note": "Production Prometheus", - "address": "http://prometheus.example.com:9090", - "edge_cluster_name": "default", - "updated_at": 1712000000, - "payload": null, - "alerting_enabled": true - } - ] + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } } @@ -1750,29 +1749,56 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DataSourceListRequest" + "$ref": "#/components/schemas/AlertRuleV2" }, "example": { - "type": "prometheus" + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "enabled": true, + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 + ], + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + } } } } } } }, - "/monit/rule/update/fields": { + "/monit/rule/v2/update": { "post": { - "operationId": "monit-rule-write-fields-update", - "summary": "Batch update rule fields", - "description": "Update specific fields across multiple alert rules at once. Only the fields listed in `fields` are applied.", + "operationId": "monit-rule-write-update-v2", + "summary": "Update alert rule (V2)", + "description": "Replace an alert rule's V2 configuration in full by ID. Returns the updated rule.", "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- Include the field names you want to update in the `fields` array, e.g. `[\"enabled\", \"channel_ids\"]`.\n- Only the specified fields are updated; others are left unchanged.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-fields-update", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **300 requests/minute**; **20 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- `id` is required and the rule must already exist; otherwise the call returns `InvalidParameter`.\n- This is a full-field replacement: except for the cases below, fields you omit are stored as zero values. Fetch the full configuration via `/monit/rule/v2/info` before modifying it.\n- `enabled` must be passed explicitly (including `false`); omitting it returns `InvalidParameter`. Setting it to `false` clears the rule's active alerts.\n- `investigation_targets` is the exception: omit it to keep the current value, pass `[]` to clear, or pass a value to replace it entirely.\n- `folder_id` cannot be changed through this operation; use `/monit/rule/move` to move the rule to another folder.\n- `account_id`, `creator_*`, `updater_*`, `created_at`, and `updated_at` are maintained by the server; client-supplied values are ignored.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- The request body tolerates additional unknown fields (forward compatibility); they are ignored.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-update-v2", "metadata": { - "sidebarTitle": "Batch update rule fields" + "sidebarTitle": "Update alert rule (V2)" } }, "responses": { @@ -1789,7 +1815,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleNameMessageListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } } } @@ -1797,16 +1823,70 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "name": "CPU High", - "message": "" + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } }, - { - "name": "Disk High", - "message": "" - } - ] + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712003600 + } } } } @@ -1829,36 +1909,74 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleFieldsUpdateRequest" + "$ref": "#/components/schemas/AlertRuleV2" }, "example": { - "ids": [ - 50001, - 50002 + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" ], - "fields": [ - "enabled" + "enabled": true, + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 ], - "enabled": false + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "id": 50001 } } } } } }, - "/monit/rule/counter/channel": { + "/monit/query/data": { "post": { - "operationId": "monit-rule-read-counter-channel", - "summary": "Get rule counts by channel", - "description": "Return an object mapping channel name to the number of rules routing alerts to that channel. If a channel name cannot be resolved, the channel ID (as a string) is used as the key.", + "operationId": "monit-read-query-data", + "summary": "Query structured data", + "description": "Run a synchronous ad-hoc query against a configured data source and return a stable `query_result.v1` result whose natural shape is frames, records, or samples. This public API requires monit-edge v0.65.0 or later.", "tags": [ - "Monitors/Alert rules" + "Monitors/Diagnostics" ], "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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-channel", + "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.", + "href": "/en/api-reference/monitors/diagnostics/monit-read-query-data", "metadata": { - "sidebarTitle": "Get rule counts by channel" + "sidebarTitle": "Query structured data" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/QueryDataRequest" + }, + "example": { + "ds_type": "prometheus", + "ds_name": "prod-prom", + "expr": "sum by (job) (rate(http_requests_total[5m]))", + "delay_seconds": 0, + "args": {} + } + } } }, "responses": { @@ -1875,94 +1993,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleCounterChannelResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "Production": 8 - } - } - } - } - }, - "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/RuleEmptyRequest" - }, - "example": {} - } - } - } - } - }, - "/monit/query/data": { - "post": { - "operationId": "monit-read-query-data", - "summary": "Query structured data", - "description": "Run a synchronous ad-hoc query against a configured data source and return a stable `query_result.v1` result whose natural shape is frames, records, or samples. This public API requires monit-edge v0.65.0 or later.", - "tags": [ - "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.", - "href": "/en/api-reference/monitors/diagnostics/monit-read-query-data", - "metadata": { - "sidebarTitle": "Query structured data" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/QueryDataRequest" - }, - "example": { - "ds_type": "prometheus", - "ds_name": "prod-prom", - "expr": "sum by (job) (rate(http_requests_total[5m]))", - "delay_seconds": 0, - "args": {} - } - } - } - }, - "responses": { - "200": { - "description": "Success", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/QueryDataResponse" + "$ref": "#/components/schemas/QueryDataResponse" } } } @@ -2401,7 +2432,7 @@ }, "ds_type": { "type": "string", - "description": "Datasource type identifier; allowed values are listed by `POST /monit/rule/dstypes` (e.g. `prometheus`, `elasticsearch`)." + "description": "Datasource type identifier (e.g. `prometheus`, `elasticsearch`)." }, "ds_list": { "type": "array", @@ -2884,31 +2915,6 @@ "$ref": "#/components/schemas/AlertRuleExport" } }, - "AlertRuleInfoResponse": { - "allOf": [ - { - "$ref": "#/components/schemas/AlertRule" - } - ], - "description": "Full alert rule returned by the info endpoint. All server-assigned fields are guaranteed present.", - "required": [ - "id", - "account_id", - "folder_id", - "name", - "ds_type", - "enabled", - "debug_log_enabled", - "cron_pattern", - "delay_seconds", - "creator_id", - "creator_name", - "updater_id", - "updater_name", - "created_at", - "updated_at" - ] - }, "DSClickHouseConfig": { "type": "object", "description": "ClickHouse datasource configuration. TLS fields are inherited from TLSClientConfig.", @@ -3401,41 +3407,6 @@ } } }, - "DSType": { - "type": "object", - "description": "A datasource type definition usable by alert rules.", - "required": [ - "id", - "name", - "ident", - "account_id", - "weight" - ], - "properties": { - "id": { - "type": "integer", - "format": "uint64", - "description": "ID of the datasource type record." - }, - "name": { - "type": "string", - "description": "Display name, e.g. `Prometheus`." - }, - "ident": { - "type": "string", - "description": "Identifier used as the `ds_type` of rules, e.g. `prometheus`." - }, - "account_id": { - "type": "integer", - "format": "uint64", - "description": "Owning account ID. `0` for global types." - }, - "weight": { - "type": "integer", - "description": "Display order weight; higher appears first." - } - } - }, "DSVictoriaLogsConfig": { "type": "object", "description": "VictoriaLogs datasource configuration. TLS fields are inherited from TLSClientConfig.", @@ -4051,14 +4022,6 @@ "format": "int64" } }, - "RuleCounterNodeResponse": { - "type": "object", - "description": "Map of top-level folder name to rule count.", - "additionalProperties": { - "type": "integer", - "format": "int64" - } - }, "RuleCounterTotalResponse": { "type": "array", "description": "Historical rule-count samples ordered by `clock` ascending.", @@ -4066,13 +4029,6 @@ "$ref": "#/components/schemas/AlertRuleCounter" } }, - "RuleDsTypesResponse": { - "type": "array", - "description": "Datasource types available to the account — global types plus account-scoped types.", - "items": { - "$ref": "#/components/schemas/DSType" - } - }, "RuleEmptyRequest": { "type": "object", "description": "No parameters required.", @@ -4131,7 +4087,7 @@ }, "ds_type": { "type": "string", - "description": "Datasource type identifier; allowed values are listed by `POST /monit/rule/dstypes`. Effective only when `fields` includes `ds_type`." + "description": "Datasource type identifier. Effective only when `fields` includes `ds_type`." }, "ds_list": { "type": "array", @@ -5039,6 +4995,525 @@ "reason" ], "type": "object" + }, + "AlertRuleV2": { + "type": "object", + "description": "Complete V2 alert rule configuration. The core difference from V1 lives in `rule_configs`: the three checkers describe recovery and ending semantics with the lifecycle v2 `recovery_mode`/`end_mode` enums.", + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "description": "Rule ID. Required on update; omit on create (assigned by the server)." + }, + "account_id": { + "type": "integer", + "format": "uint64", + "description": "Account ID, filled by the server from the authentication context; any client-supplied value is ignored." + }, + "folder_id": { + "type": "integer", + "format": "uint64", + "description": "ID of the folder the rule belongs to; list folders via `POST /monit/folder/list`. Cannot be changed through the update API — use `/monit/rule/move` instead." + }, + "name": { + "type": "string", + "description": "Rule name. Must be unique within the folder and at most 128 characters." + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Custom labels." + }, + "ds_type": { + "type": "string", + "description": "Datasource type identifier (e.g. `prometheus`, `elasticsearch`)." + }, + "ds_list": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Datasource name match patterns (wildcards supported). At least one of `ds_list` / `ds_ids` must be non-empty; both are merged to decide which datasources the rule monitors." + }, + "ds_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "Datasource ID list, merged with `ds_list` to decide the monitored datasources; IDs survive datasource renames. At least one of `ds_list` / `ds_ids` must be provided." + }, + "enabled": { + "type": "boolean", + "description": "Whether the rule is enabled. Required — the server enforces an explicit value (including `false`) while decoding. Setting it to `false` on update clears the rule's active alerts." + }, + "debug_log_enabled": { + "type": "boolean", + "description": "Enable debug logging; the edge then emits detailed evaluation logs for this rule, useful when the rule does not trigger as expected." + }, + "rule_configs": { + "$ref": "#/components/schemas/AlertRuleConfigsV2", + "description": "Detection configuration: query list plus trigger/recovery conditions. See `AlertRuleConfigsV2`." + }, + "cron_pattern": { + "type": "string", + "description": "Schedule expression: a 6-field cron (with seconds) or an `@every 30s` interval. Must not start with `CRON_TZ=` or `TZ=`; set the timezone in the `timezone` field instead." + }, + "timezone": { + "type": "string", + "default": "Asia/Shanghai", + "description": "Timezone the rule runs in; it decides how the cron schedule and enabled time windows are interpreted. Only IANA names are accepted (e.g. `Asia/Shanghai`, `UTC`, `Europe/London`); abbreviations or offsets like `Local`, `UTC+8`, `CST` are rejected. Empty falls back to `Asia/Shanghai`." + }, + "delay_seconds": { + "type": "integer", + "description": "Seconds the evaluation query window is shifted back, compensating for data ingestion latency." + }, + "enabled_times": { + "type": "array", + "description": "Time windows during which the rule is in effect. When omitted or empty, the rule is active 00:00–23:59 every day.", + "default": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "items": { + "type": "object", + "properties": { + "days": { + "type": "array", + "items": { + "type": "integer" + }, + "description": "Days of week (0=Sunday)." + }, + "stime": { + "type": "string", + "description": "Start time, e.g. `09:00`." + }, + "etime": { + "type": "string", + "description": "End time, e.g. `18:00`." + } + } + } + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Extra annotation key-value pairs delivered with alert events; keys must not start with `$` (reserved for query fields)." + }, + "description_type": { + "type": "string", + "enum": [ + "text", + "markdown" + ], + "default": "text", + "description": "Format of the description content. Empty or omitted defaults to `text`. `text` = plain text; `markdown` = Markdown, rendered as such in alert details." + }, + "description": { + "type": "string", + "description": "Rule description, Markdown format." + }, + "channel_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "Collaboration space IDs alerts are sent to. May be empty; alerts then route through the global integration." + }, + "repeat_interval": { + "type": "integer", + "format": "int64", + "description": "Notification repeat interval in seconds. Values below 1 fall back to the default 3600." + }, + "repeat_total": { + "type": "integer", + "format": "int64", + "description": "Maximum number of repeat notifications. Values below 1 fall back to the default 3." + }, + "investigation_targets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InvestigationTarget" + }, + "description": "Drill-down entries linked from the alert event detail page; at most 20 items, duplicates rejected. On update the field is presence-based: omit it to keep the current value, pass `[]` to clear.", + "x-flashduty-preserve-absence": true + }, + "creator_id": { + "type": "integer", + "format": "uint64", + "description": "Creator member ID, filled by the server from the current user; any client-supplied value is ignored." + }, + "creator_name": { + "type": "string", + "description": "Creator name, filled by the server; any client-supplied value is ignored." + }, + "updater_id": { + "type": "integer", + "format": "uint64", + "description": "ID of the member who last updated the rule, filled by the server; any client-supplied value is ignored." + }, + "updater_name": { + "type": "string", + "description": "Name of the member who last updated the rule, filled by the server; any client-supplied value is ignored." + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "Creation time as a Unix timestamp in seconds, generated by the server; any client-supplied value is ignored." + }, + "updated_at": { + "type": "integer", + "format": "int64", + "description": "Last update time as a Unix timestamp in seconds, generated by the server; any client-supplied value is ignored." + } + }, + "required": [ + "folder_id", + "name", + "ds_type", + "enabled", + "cron_pattern", + "rule_configs" + ] + }, + "AlertRuleConfigsV2": { + "type": "object", + "description": "V2 rule evaluation configuration.", + "properties": { + "queries": { + "type": "array", + "description": "Query list with at least one entry; each needs a unique `name` (`R` and `__all__` are reserved) and a non-empty, non-duplicated `expr`.", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Query identifier (e.g. `A`), must match `[A-Za-z][A-Za-z0-9_]*`; `R` and `__all__` are reserved and cannot be used." + }, + "expr": { + "type": "string", + "description": "Query expression." + }, + "label_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Result fields used as alert event labels; rows with the same label set form one alert. Must not overlap `value_fields`; applies to tabular results (SQL/ES-like datasources)." + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Numeric result fields evaluated by threshold expressions (referenced as `$A.`); required for threshold checks when the datasource is not `prometheus`/`loki`/`victorialogs`. Field names must not contain `.`." + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Datasource-specific query parameters; keys follow the `.` convention (e.g. `es.type`, `tencent_cls.limit`). Most datasources need none." + } + } + } + }, + "relate_queries": { + "type": "array", + "description": "Optional auxiliary queries whose results attach to alert events as context. Each entry needs a unique `name` (not colliding with any query name) and a non-empty `expr`.", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Auxiliary query identifier." + }, + "expr": { + "type": "string", + "description": "Query expression." + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Datasource-specific parameters for the auxiliary query; same convention as `queries[].args`." + } + } + } + }, + "check_threshold": { + "$ref": "#/components/schemas/AlertRuleThresholdV2", + "description": "Threshold check configuration. See `AlertRuleThresholdV2`." + }, + "check_anydata": { + "$ref": "#/components/schemas/AlertRuleAnyDataV2", + "description": "Any-data check configuration: fires when a query returns any data row. See `AlertRuleAnyDataV2`." + }, + "check_nodata": { + "$ref": "#/components/schemas/AlertRuleNoDataV2", + "description": "No-data check configuration. See `AlertRuleNoDataV2`." + } + }, + "required": [ + "queries" + ] + }, + "AlertRuleThresholdV2": { + "type": "object", + "description": "Threshold check configuration (lifecycle v2).", + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether the threshold check is enabled." + }, + "alerting_check_times": { + "type": "integer", + "description": "Fire after the alert condition is met this many times; when enabled, minimum 1 and maximum 10000. Combined with `alerting_window_size` it means at least N hits within the last M evaluations." + }, + "alerting_window_size": { + "type": "integer", + "description": "Optional sliding window size M: fire only when the condition is met at least `alerting_check_times` times within the last M evaluations. Omit for consecutive mode (N consecutive hits). Must satisfy `alerting_check_times` <= M <= 10000." + }, + "recovery_check_times": { + "type": "integer", + "description": "Recover after the recovery condition is met this many times; minimum 1 when enabled." + }, + "critical": { + "type": "string", + "description": "Critical threshold expression referencing query results as `$` or `$.`, e.g. `$A > 90`; when enabled at least one of the three severities must be set." + }, + "warning": { + "type": "string", + "description": "Warning threshold expression; same syntax as `critical`." + }, + "info": { + "type": "string", + "description": "Info threshold expression; same syntax as `critical`." + }, + "recovery_mode": { + "type": "string", + "enum": [ + "condition_clear", + "expression_match", + "recovery_query_match", + "manual" + ], + "description": "How recovery is decided (lifecycle v2); required when enabled. `condition_clear` = recover once the alert expression no longer holds; `recovery` is not allowed. `expression_match` = recover when the `recovery.expr` threshold expression holds. `recovery_query_match` = recover when the `recovery.expr` query expression evaluates true. `manual` = never recover automatically; alerts need manual handling, no recovery event is pushed, and `recovery` is not allowed." + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "Recovery evaluation config. Required (with non-empty `recovery.expr`) only when `recovery_mode` is `expression_match` or `recovery_query_match`; must be omitted for the other modes." + } + } + }, + "AlertRuleAnyDataV2": { + "type": "object", + "description": "Any-data check configuration (lifecycle v2). Fires when a query returns any data row.", + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether the any-data check is enabled: any returned data row triggers an alert." + }, + "alerting_check_times": { + "type": "integer", + "description": "Fire after the alert condition is met this many times; when enabled, minimum 1 and maximum 10000. Combined with `alerting_window_size` it means at least N hits within the last M evaluations." + }, + "alerting_window_size": { + "type": "integer", + "description": "Optional sliding window size M: fire only when the condition is met at least `alerting_check_times` times within the last M evaluations. Omit for consecutive mode. Must satisfy `alerting_check_times` <= M <= 10000." + }, + "recovery_check_times": { + "type": "integer", + "description": "Recover after the recovery condition is met this many times; minimum 1 when enabled." + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "Severity of any-data alerts, case-sensitive; required when enabled." + }, + "recovery_mode": { + "type": "string", + "enum": [ + "data_absent", + "recovery_query_match", + "manual" + ], + "description": "How recovery is decided (lifecycle v2); required when enabled. `data_absent` = recover when the query returns no data; `recovery` is not allowed. `recovery_query_match` = recover when the `recovery.expr` query expression evaluates true; only a single query (`name=A`) is allowed. `manual` = never recover automatically; alerts need manual handling, no recovery event is pushed, and `recovery` is not allowed." + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "Recovery evaluation config. Required (with non-empty `recovery.expr`) only when `recovery_mode` is `recovery_query_match`; must be omitted for the other modes." + } + } + }, + "AlertRuleNoDataV2": { + "type": "object", + "description": "No-data check configuration (lifecycle v2).", + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether the per-series no-data check is enabled: series that previously reported data trigger an alert when data disappears." + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "Severity of no-data alerts, case-sensitive; required when the per-series check is enabled." + }, + "alert_on_empty_result": { + "type": "boolean", + "description": "Whether to alert when all queries return empty results (global empty-result check)." + }, + "alert_on_empty_result_severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "Severity of empty-result alerts, case-sensitive; only takes effect and is required when `alert_on_empty_result` is on." + }, + "alerting_check_times": { + "type": "integer", + "description": "Fire after the alert condition is met this many times; when enabled, minimum 1 and maximum 10000. Combined with `alerting_window_size` it means at least N hits within the last M evaluations." + }, + "alerting_window_size": { + "type": "integer", + "description": "Optional sliding window size M: fire only when the condition is met at least `alerting_check_times` times within the last M evaluations. Omit for consecutive mode. Must satisfy `alerting_check_times` <= M <= 10000." + }, + "recovery_check_times": { + "type": "integer", + "description": "Recover after the recovery condition is met this many times; minimum 1 when enabled." + }, + "end_mode": { + "type": "string", + "enum": [ + "data_reappears", + "data_reappears_or_timeout", + "manual" + ], + "description": "How a no-data alert ends (lifecycle v2); required when enabled. `data_reappears` = recover when data reappears. `data_reappears_or_timeout` = end when data reappears or after `auto_close_after_seconds` seconds, whichever comes first; requires the per-series no-data check and a positive `auto_close_after_seconds`. `manual` = never end automatically; alerts need manual handling and no recovery event is pushed. For `data_reappears` and `manual`, `auto_close_after_seconds` must be 0." + }, + "auto_close_after_seconds": { + "type": "integer", + "format": "int64", + "description": "Seconds to wait before auto-closing. Allowed and required to be positive only when `end_mode` is `data_reappears_or_timeout`; must be 0 for the other modes." + } + } + }, + "AlertRuleRecoveryQueryV2": { + "type": "object", + "description": "Recovery evaluation configuration for lifecycle v2.", + "properties": { + "expr": { + "type": "string", + "description": "Recovery condition expression: a threshold expression (e.g. `$A < 90`) in `expression_match` mode, a query expression in `recovery_query_match` mode. Required and non-empty when the corresponding mode is enabled." + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Numeric result fields the recovery expression references as `$A.`; same semantics as a query's `value_fields`. Not returned when empty." + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Datasource-specific parameters for the recovery query; keys follow the same `.` convention as a query's `args`. Not returned when empty." + } + } + }, + "InvestigationTarget": { + "type": "object", + "description": "Drill-down entry linked to alert events. A deliberately closed tagged union: new kinds require explicit server support.", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dashboard" + ], + "description": "Entry type; currently only `dashboard` is supported." + }, + "dashboard": { + "$ref": "#/components/schemas/DashboardInvestigationTarget", + "description": "Configuration for the `dashboard` kind; required when `kind` is `dashboard`." + } + }, + "required": [ + "kind" + ] + }, + "DashboardInvestigationTarget": { + "type": "object", + "description": "Configuration of a dashboard drill-down entry.", + "properties": { + "dashboard_id": { + "type": "string", + "description": "Target dashboard ID; must be a canonical UUIDv7." + }, + "target_id": { + "type": "string", + "description": "Panel ID inside the dashboard; must be a canonical UUIDv7. Optional." + }, + "variable_bindings": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/InvestigationVariableBinding" + }, + "description": "Dashboard variable bindings, keyed by dashboard variable name." + } + }, + "required": [ + "dashboard_id" + ] + }, + "InvestigationVariableBinding": { + "type": "object", + "description": "Binding between a dashboard variable and alert event data.", + "properties": { + "source": { + "type": "string", + "enum": [ + "event_label" + ], + "description": "Where the bound value comes from; currently only `event_label` (the alert event's label value) is supported." + }, + "key": { + "type": "string", + "description": "Alert event label name; must follow Prometheus label naming rules and must not be a reserved label." + } + }, + "required": [ + "source", + "key" + ] } } } diff --git a/api-reference/monitors.openapi.zh.json b/api-reference/monitors.openapi.zh.json index da729118..f7f21efb 100644 --- a/api-reference/monitors.openapi.zh.json +++ b/api-reference/monitors.openapi.zh.json @@ -364,77 +364,6 @@ } } }, - "/monit/rule/counter/node": { - "post": { - "operationId": "monit-rule-read-counter-node", - "summary": "按文件夹节点查询规则统计", - "description": "返回一个对象,key 为顶层文件夹名称,value 为该文件夹及其子孙下的规则总数。", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-node", - "metadata": { - "sidebarTitle": "按文件夹节点查询规则统计" - } - }, - "responses": { - "200": { - "description": "成功", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/RuleCounterNodeResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "Production": 10, - "Staging": 3 - } - } - } - } - }, - "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/RuleEmptyRequest" - }, - "example": {} - } - } - } - } - }, "/monit/rule/audit/detail": { "post": { "operationId": "monit-rule-read-audit-detail", @@ -1080,19 +1009,19 @@ } } }, - "/monit/rule/info": { + "/monit/rule/delete": { "post": { - "operationId": "monit-rule-read-info", - "summary": "查看告警规则详情", - "description": "通过 ID 返回告警规则的完整配置,包括规则查询、阈值和通知设置。", + "operationId": "monit-rule-write-delete", + "summary": "删除告警规则", + "description": "通过 ID 删除单条告警规则。", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-info", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-delete", "metadata": { - "sidebarTitle": "查看告警规则详情" + "sidebarTitle": "删除告警规则" } }, "responses": { @@ -1109,7 +1038,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRuleInfoResponse" + "$ref": "#/components/schemas/RuleEmptyResponse" } } } @@ -1117,20 +1046,7 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "id": 50001, - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "channel_ids": [ - 20001 - ] - } + "data": {} } } } @@ -1163,19 +1079,19 @@ } } }, - "/monit/rule/delete": { + "/monit/rule/import": { "post": { - "operationId": "monit-rule-write-delete", - "summary": "删除告警规则", - "description": "通过 ID 删除单条告警规则。", + "operationId": "monit-rule-write-import", + "summary": "导入告警规则", + "description": "从 JSON 数组导入一条或多条告警规则,返回每条规则的导入结果(成功或失败)。", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-delete", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **20 次/分钟**;**2 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 请求体为规则导出对象的 JSON 数组(与 `POST /monit/rule/export` 输出兼容)。\n- 每个对象必须包含 `folder_id`、`ds_type` 以及 `ds_list` 或 `ds_ids` 之一。\n- 部分规则可能失败(如名称重复),请检查每条结果的状态。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-import", "metadata": { - "sidebarTitle": "删除告警规则" + "sidebarTitle": "导入告警规则" } }, "responses": { @@ -1192,7 +1108,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleEmptyResponse" + "$ref": "#/components/schemas/RuleImportResponse" } } } @@ -1200,7 +1116,12 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": {} + "data": [ + { + "name": "CPU High", + "message": "" + } + ] } } } @@ -1223,29 +1144,46 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleIDRequest" + "$ref": "#/components/schemas/RuleImportRequest" }, - "example": { - "id": 50001 - } + "example": [ + { + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "enabled": true, + "cron_pattern": "0 * * * * *", + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "avg(cpu_usage_idle) < 10" + } + ] + } + } + ] } } } } }, - "/monit/rule/dstypes": { + "/monit/rule/list/basic": { "post": { - "operationId": "monit-rule-read-dstypes", - "summary": "查询可用的数据源类型", - "description": "返回当前账户在创建告警规则时可使用的数据源类型(`DSType` 记录)列表,包括全局类型和账户自定义类型。", + "operationId": "monit-rule-read-list", + "summary": "查询告警规则列表", + "description": "返回指定文件夹下所有告警规则的基础信息。如需完整规则详情,请调用 `POST /monit/rule/v2/info`。", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-dstypes", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |\n\n## 使用说明\n\n- 将 `folder_id` 设为 `0` 可列出当前用户有权查看的所有文件夹下的规则。\n- `triggered` 字段表示该规则当前是否有活跃告警。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-list", "metadata": { - "sidebarTitle": "查询可用的数据源类型" + "sidebarTitle": "查询告警规则列表" } }, "responses": { @@ -1262,7 +1200,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleDsTypesResponse" + "$ref": "#/components/schemas/RuleBasicListResponse" } } } @@ -1272,11 +1210,15 @@ "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", "data": [ { - "id": 1, - "name": "Prometheus", - "ident": "prometheus", - "account_id": 0, - "weight": 100 + "id": 50001, + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "enabled": true, + "triggered": true, + "created_at": 1710000000, + "active_alert_count": 2, + "runtime_state": "normal" } ] } @@ -1301,27 +1243,29 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleEmptyRequest" + "$ref": "#/components/schemas/RuleListRequest" }, - "example": {} + "example": { + "folder_id": 100 + } } } } } }, - "/monit/rule/update": { + "/monit/datasource/list": { "post": { - "operationId": "monit-rule-write-update", - "summary": "更新告警规则", - "description": "替换已有告警规则的完整配置,所有字段将被覆盖。", + "operationId": "monit-datasource-read-list", + "summary": "查询数据源列表", + "description": "返回当前账户下的所有数据源,可通过 `type_ident` 过滤类型。 支持诊断类型 redis_node、redis_sentinel、mongodb_mongod、mongodb_mongos 和 kafka;enabled 与 alerting_enabled 相互独立。", "tags": [ - "Monitors/告警规则" + "Monitors/告警数据源" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `id` 为必填项。其他字段与 `POST /monit/rule/create` 的规则相同。\n- 名称在所在文件夹内必须保持唯一;重名会返回 `InvalidParameter`。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-update", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **数据源查看**(`monit`) |\n\n## 使用说明\n\n- 省略 `type_ident` 可返回所有类型的数据源。\n- 列表响应中不返回敏感凭证字段(密码、密钥)。\n\n完整支持类型与凭据行为见请求/响应 Schema。仅诊断类型不能启用告警。创建时省略 enabled 默认为 true,更新时省略保留当前值;enabled 或 alerting_enabled 的显式 null 非法。诊断密码及 Kafka 私钥在响应中省略,环境变量引用除外;更新时省略秘密字段保留原值,空字符串清除。其他数据源凭据可能返回,应作为敏感数据处理。", + "href": "/zh/api-reference/monitors/data-sources/monit-datasource-read-list", "metadata": { - "sidebarTitle": "更新告警规则" + "sidebarTitle": "查询数据源列表" } }, "responses": { @@ -1338,7 +1282,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/DataSourceListResponse" } } } @@ -1346,10 +1290,21 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "id": 50001, - "updated_at": 1712100000 - } + "data": [ + { + "id": 10, + "account_id": 10023, + "type_ident": "prometheus", + "name": "Prometheus Prod", + "enabled": true, + "note": "Production Prometheus", + "address": "http://prometheus.example.com:9090", + "edge_cluster_name": "default", + "updated_at": 1712000000, + "payload": null, + "alerting_enabled": true + } + ] } } } @@ -1372,45 +1327,29 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/DataSourceListRequest" }, "example": { - "id": 50001, - "folder_id": 100, - "name": "CPU High v2", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "rule_configs": { - "queries": [ - { - "name": "A", - "expr": "avg(cpu_usage_idle) < 5" - } - ] - } + "type": "prometheus" } } } } } }, - "/monit/rule/import": { + "/monit/rule/update/fields": { "post": { - "operationId": "monit-rule-write-import", - "summary": "导入告警规则", - "description": "从 JSON 数组导入一条或多条告警规则,返回每条规则的导入结果(成功或失败)。", + "operationId": "monit-rule-write-fields-update", + "summary": "批量更新规则字段", + "description": "一次性更新多条告警规则的特定字段,仅应用 `fields` 列表中指定的字段。", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **20 次/分钟**;**2 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 请求体为规则导出对象的 JSON 数组(与 `POST /monit/rule/export` 输出兼容)。\n- 每个对象必须包含 `folder_id`、`ds_type` 以及 `ds_list` 或 `ds_ids` 之一。\n- 部分规则可能失败(如名称重复),请检查每条结果的状态。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-import", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 在 `fields` 数组中指定要更新的字段名,如 `[\"enabled\", \"channel_ids\"]`。\n- 仅更新指定字段,其他字段保持不变。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-fields-update", "metadata": { - "sidebarTitle": "导入告警规则" + "sidebarTitle": "批量更新规则字段" } }, "responses": { @@ -1427,7 +1366,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleImportResponse" + "$ref": "#/components/schemas/RuleNameMessageListResponse" } } } @@ -1439,6 +1378,10 @@ { "name": "CPU High", "message": "" + }, + { + "name": "Disk High", + "message": "" } ] } @@ -1463,46 +1406,36 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleImportRequest" + "$ref": "#/components/schemas/RuleFieldsUpdateRequest" }, - "example": [ - { - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "rule_configs": { - "queries": [ - { - "name": "A", - "expr": "avg(cpu_usage_idle) < 10" - } - ] - } - } - ] + "example": { + "ids": [ + 50001, + 50002 + ], + "fields": [ + "enabled" + ], + "enabled": false + } } } } } }, - "/monit/rule/create": { + "/monit/rule/counter/channel": { "post": { - "operationId": "monit-rule-write-create", - "summary": "创建告警规则", - "description": "创建新的告警规则,返回带有分配 ID 的已创建规则。", - "tags": [ + "operationId": "monit-rule-read-counter-channel", + "summary": "按协作空间查询规则统计", + "description": "返回一个对象,key 为协作空间名称,value 为将告警路由到该协作空间的规则数量。若协作空间名称无法解析,则以协作空间 ID(字符串形式)作为 key。", + "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `name`、`ds_type`、`cron_pattern` 和 `rule_configs.queries` 为必填项。\n- `ds_list`(支持通配符)或 `ds_ids` 必须有一个非空。\n- `cron_pattern` 使用标准 5 字段 cron 语法。\n- `channel_ids` 可为空,告警将通过全局集成路由。\n- `name` 在 `folder_id` 内必须唯一;重名会返回 `InvalidParameter`。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-create", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-channel", "metadata": { - "sidebarTitle": "创建告警规则" + "sidebarTitle": "按协作空间查询规则统计" } }, "responses": { @@ -1519,7 +1452,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleCounterChannelResponse" } } } @@ -1528,11 +1461,7 @@ "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", "data": { - "id": 50001, - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "created_at": 1712000000 + "Production": 8 } } } @@ -1556,57 +1485,27 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleEmptyRequest" }, - "example": { - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "ds_list": [ - "prometheus*" - ], - "enabled": true, - "cron_pattern": "0 * * * * *", - "channel_ids": [ - 20001 - ], - "rule_configs": { - "queries": [ - { - "name": "A", - "expr": "avg(cpu_usage_idle) < 10" - } - ], - "check_threshold": { - "enabled": true, - "critical": "A", - "alerting_check_times": 1, - "recovery_check_times": 1, - "push_recovery_event": true, - "recovery": { - "mode": "invert" - } - } - } - } + "example": {} } } } } }, - "/monit/rule/list/basic": { + "/monit/rule/v2/info": { "post": { - "operationId": "monit-rule-read-list", - "summary": "查询告警规则列表", - "description": "返回指定文件夹下所有告警规则的基础信息。如需完整规则详情,请调用 `POST /monit/rule/info`。", + "operationId": "monit-rule-read-info-v2", + "summary": "获取告警规则详情 V2", + "description": "通过 ID 返回告警规则的完整 V2 配置,包含 lifecycle v2 的恢复与结束模式设置。", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |\n\n## 使用说明\n\n- 将 `folder_id` 设为 `0` 可列出当前用户有权查看的所有文件夹下的规则。\n- `triggered` 字段表示该规则当前是否有活跃告警。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-list", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |\n\n## 使用说明\n\n- `id` 必填且不能为 `0`,否则返回 `InvalidParameter`。\n- 规则不存在时返回 `InvalidParameter`(`alert rule not found`)。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-info-v2", "metadata": { - "sidebarTitle": "查询告警规则列表" + "sidebarTitle": "获取告警规则详情 V2" } }, "responses": { @@ -1623,7 +1522,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleBasicListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } } } @@ -1631,19 +1530,70 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "id": 50001, - "folder_id": 100, - "name": "CPU High", - "ds_type": "prometheus", - "enabled": true, - "triggered": true, - "created_at": 1710000000, - "active_alert_count": 2, - "runtime_state": "normal" - } - ] + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } } @@ -1666,29 +1616,29 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleListRequest" + "$ref": "#/components/schemas/RuleIDRequest" }, "example": { - "folder_id": 100 + "id": 50001 } } } } } }, - "/monit/datasource/list": { + "/monit/rule/v2/create": { "post": { - "operationId": "monit-datasource-read-list", - "summary": "查询数据源列表", - "description": "返回当前账户下的所有数据源,可通过 `type_ident` 过滤类型。 支持诊断类型 redis_node、redis_sentinel、mongodb_mongod、mongodb_mongos 和 kafka;enabled 与 alerting_enabled 相互独立。", + "operationId": "monit-rule-write-create-v2", + "summary": "创建告警规则 V2", + "description": "创建新的 V2 告警规则,返回带有分配 ID 的已创建规则。", "tags": [ - "Monitors/告警数据源" + "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **数据源查看**(`monit`) |\n\n## 使用说明\n\n- 省略 `type_ident` 可返回所有类型的数据源。\n- 列表响应中不返回敏感凭证字段(密码、密钥)。\n\n完整支持类型与凭据行为见请求/响应 Schema。仅诊断类型不能启用告警。创建时省略 enabled 默认为 true,更新时省略保留当前值;enabled 或 alerting_enabled 的显式 null 非法。诊断密码及 Kafka 私钥在响应中省略,环境变量引用除外;更新时省略秘密字段保留原值,空字符串清除。其他数据源凭据可能返回,应作为敏感数据处理。", - "href": "/zh/api-reference/monitors/data-sources/monit-datasource-read-list", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **300 次/分钟**;**20 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `name`、`ds_type`、`enabled`、`cron_pattern` 和 `rule_configs.queries` 为必填项;`ds_list`(支持通配符)或 `ds_ids` 必须有一个非空。\n- `enabled` 必须显式传入(包括 `false`),缺失时返回 `InvalidParameter`。\n- `id`、`account_id`、`creator_*`、`updater_*`、`created_at`、`updated_at` 由服务端赋值,客户端传入将被忽略。\n- `name` 在 `folder_id` 内必须唯一;重名会返回 `InvalidParameter`。\n- `channel_ids` 可为空,告警将通过全局集成路由。\n- 请求体容忍额外的未知字段(向前兼容),未知字段会被忽略。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-create-v2", "metadata": { - "sidebarTitle": "查询数据源列表" + "sidebarTitle": "创建告警规则 V2" } }, "responses": { @@ -1705,7 +1655,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/DataSourceListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } } } @@ -1713,21 +1663,70 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "id": 10, - "account_id": 10023, - "type_ident": "prometheus", - "name": "Prometheus Prod", - "enabled": true, - "note": "Production Prometheus", - "address": "http://prometheus.example.com:9090", - "edge_cluster_name": "default", - "updated_at": 1712000000, - "payload": null, - "alerting_enabled": true - } - ] + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } } @@ -1750,29 +1749,56 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/DataSourceListRequest" + "$ref": "#/components/schemas/AlertRuleV2" }, "example": { - "type": "prometheus" + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "enabled": true, + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 + ], + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + } } } } } } }, - "/monit/rule/update/fields": { + "/monit/rule/v2/update": { "post": { - "operationId": "monit-rule-write-fields-update", - "summary": "批量更新规则字段", - "description": "一次性更新多条告警规则的特定字段,仅应用 `fields` 列表中指定的字段。", + "operationId": "monit-rule-write-update-v2", + "summary": "更新告警规则 V2", + "description": "按 ID 全量替换告警规则的 V2 配置,返回更新后的规则。", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 在 `fields` 数组中指定要更新的字段名,如 `[\"enabled\", \"channel_ids\"]`。\n- 仅更新指定字段,其他字段保持不变。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-fields-update", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **300 次/分钟**;**20 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `id` 必填且对应规则必须已存在,否则返回 `InvalidParameter`。\n- 本接口为全量字段替换语义:除下列例外外,未传入的字段按零值保存,建议先调用 `/monit/rule/v2/info` 获取完整配置后再修改。\n- `enabled` 必须显式传入(包括 `false`),缺失时返回 `InvalidParameter`;更新为 `false` 时服务端会清理该规则的活跃告警。\n- `investigation_targets` 为例外:省略时保留原配置,传 `[]` 清空,传值则整体替换。\n- `folder_id` 不可通过本接口修改,调整文件夹请使用 `/monit/rule/move`。\n- `account_id`、`creator_*`、`updater_*`、`created_at`、`updated_at` 由服务端维护,传入将被忽略。\n- `name` 在 `folder_id` 内必须唯一;重名会返回 `InvalidParameter`。\n- 请求体容忍额外的未知字段(向前兼容),未知字段会被忽略。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-update-v2", "metadata": { - "sidebarTitle": "批量更新规则字段" + "sidebarTitle": "更新告警规则 V2" } }, "responses": { @@ -1789,7 +1815,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleNameMessageListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } } } @@ -1797,16 +1823,70 @@ }, "example": { "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": [ - { - "name": "CPU High", - "message": "" + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } }, - { - "name": "Disk High", - "message": "" - } - ] + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712003600 + } } } } @@ -1829,36 +1909,74 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RuleFieldsUpdateRequest" + "$ref": "#/components/schemas/AlertRuleV2" }, "example": { - "ids": [ - 50001, - 50002 + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" ], - "fields": [ - "enabled" + "enabled": true, + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 ], - "enabled": false + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "id": 50001 } } } } } }, - "/monit/rule/counter/channel": { + "/monit/query/data": { "post": { - "operationId": "monit-rule-read-counter-channel", - "summary": "按协作空间查询规则统计", - "description": "返回一个对象,key 为协作空间名称,value 为将告警路由到该协作空间的规则数量。若协作空间名称无法解析,则以协作空间 ID(字符串形式)作为 key。", + "operationId": "monit-read-query-data", + "summary": "查询结构化数据", + "description": "对已配置的数据源执行同步即席查询,并返回稳定的 `query_result.v1` 结果;结果会按自然语义呈现为 frames、records 或 samples。此公开接口要求 monit-edge v0.65.0 或更高版本。", "tags": [ - "Monitors/告警规则" + "Monitors/诊断分析" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-channel", + "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": "按协作空间查询规则统计" + "sidebarTitle": "查询结构化数据" + } + }, + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/QueryDataRequest" + }, + "example": { + "ds_type": "prometheus", + "ds_name": "prod-prom", + "expr": "sum by (job) (rate(http_requests_total[5m]))", + "delay_seconds": 0, + "args": {} + } + } } }, "responses": { @@ -1875,94 +1993,7 @@ "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleCounterChannelResponse" - } - } - } - ] - }, - "example": { - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", - "data": { - "Production": 8 - } - } - } - } - }, - "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/RuleEmptyRequest" - }, - "example": {} - } - } - } - } - }, - "/monit/query/data": { - "post": { - "operationId": "monit-read-query-data", - "summary": "查询结构化数据", - "description": "对已配置的数据源执行同步即席查询,并返回稳定的 `query_result.v1` 结果;结果会按自然语义呈现为 frames、records 或 samples。此公开接口要求 monit-edge v0.65.0 或更高版本。", - "tags": [ - "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 秒,并在调用方放弃查询时向下传播取消信号。", - "href": "/zh/api-reference/monitors/diagnostics/monit-read-query-data", - "metadata": { - "sidebarTitle": "查询结构化数据" - } - }, - "requestBody": { - "required": true, - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/QueryDataRequest" - }, - "example": { - "ds_type": "prometheus", - "ds_name": "prod-prom", - "expr": "sum by (job) (rate(http_requests_total[5m]))", - "delay_seconds": 0, - "args": {} - } - } - } - }, - "responses": { - "200": { - "description": "成功", - "content": { - "application/json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "type": "object", - "properties": { - "data": { - "$ref": "#/components/schemas/QueryDataResponse" + "$ref": "#/components/schemas/QueryDataResponse" } } } @@ -2401,7 +2432,7 @@ }, "ds_type": { "type": "string", - "description": "数据源类型标识,可选值可通过 `POST /monit/rule/dstypes` 查询(如 `prometheus`、`elasticsearch`)。" + "description": "数据源类型标识(如 `prometheus`、`elasticsearch`)。" }, "ds_list": { "type": "array", @@ -2884,31 +2915,6 @@ "$ref": "#/components/schemas/AlertRuleExport" } }, - "AlertRuleInfoResponse": { - "allOf": [ - { - "$ref": "#/components/schemas/AlertRule" - } - ], - "description": "info 接口返回的完整告警规则,服务端赋值字段均保证存在。", - "required": [ - "id", - "account_id", - "folder_id", - "name", - "ds_type", - "enabled", - "debug_log_enabled", - "cron_pattern", - "delay_seconds", - "creator_id", - "creator_name", - "updater_id", - "updater_name", - "created_at", - "updated_at" - ] - }, "DSClickHouseConfig": { "type": "object", "description": "ClickHouse 数据源配置,TLS 字段继承自 TLSClientConfig。", @@ -3401,41 +3407,6 @@ } } }, - "DSType": { - "type": "object", - "description": "告警规则可使用的数据源类型定义。", - "required": [ - "id", - "name", - "ident", - "account_id", - "weight" - ], - "properties": { - "id": { - "type": "integer", - "format": "uint64", - "description": "数据源类型记录 ID。" - }, - "name": { - "type": "string", - "description": "显示名称,如 `Prometheus`。" - }, - "ident": { - "type": "string", - "description": "作为规则 `ds_type` 的标识符,如 `prometheus`。" - }, - "account_id": { - "type": "integer", - "format": "uint64", - "description": "所属账户 ID;`0` 表示全局类型。" - }, - "weight": { - "type": "integer", - "description": "排序权重,值越大越靠前。" - } - } - }, "DSVictoriaLogsConfig": { "type": "object", "description": "VictoriaLogs 数据源配置,TLS 字段继承自 TLSClientConfig。", @@ -4051,14 +4022,6 @@ "format": "int64" } }, - "RuleCounterNodeResponse": { - "type": "object", - "description": "顶层文件夹名称到规则数量的映射。", - "additionalProperties": { - "type": "integer", - "format": "int64" - } - }, "RuleCounterTotalResponse": { "type": "array", "description": "按 `clock` 升序排列的规则数量历史采样。", @@ -4066,13 +4029,6 @@ "$ref": "#/components/schemas/AlertRuleCounter" } }, - "RuleDsTypesResponse": { - "type": "array", - "description": "当前账户可使用的数据源类型列表,包括全局类型和账户自定义类型。", - "items": { - "$ref": "#/components/schemas/DSType" - } - }, "RuleEmptyRequest": { "type": "object", "description": "不需要任何参数。", @@ -4131,7 +4087,7 @@ }, "ds_type": { "type": "string", - "description": "数据源类型标识,可选值可通过 `POST /monit/rule/dstypes` 查询。仅当 `fields` 包含 `ds_type` 时生效。" + "description": "数据源类型标识。仅当 `fields` 包含 `ds_type` 时生效。" }, "ds_list": { "type": "array", @@ -5039,6 +4995,525 @@ "reason" ], "type": "object" + }, + "AlertRuleV2": { + "type": "object", + "description": "完整的 V2 告警规则配置。与 V1 的核心差异在 `rule_configs`:三个检查器使用 lifecycle v2 的 `recovery_mode`/`end_mode` 枚举描述恢复与结束语义。", + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "description": "规则 ID。更新时必填,创建时省略(服务端自动分配)。" + }, + "account_id": { + "type": "integer", + "format": "uint64", + "description": "账户 ID,由服务端按认证信息自动填充,客户端传入将被忽略。" + }, + "folder_id": { + "type": "integer", + "format": "uint64", + "description": "规则所属文件夹 ID,可通过 `POST /monit/folder/list` 获取。创建后不可通过更新接口修改,调整文件夹请使用 `/monit/rule/move`。" + }, + "name": { + "type": "string", + "description": "规则名称,同一文件夹内必须唯一,最长 128 个字符。" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "自定义标签。" + }, + "ds_type": { + "type": "string", + "description": "数据源类型标识(如 `prometheus`、`elasticsearch`)。" + }, + "ds_list": { + "type": "array", + "items": { + "type": "string" + }, + "description": "数据源名称匹配模式(支持通配符)。`ds_list` / `ds_ids` 至少一个非空,两者合并共同决定规则监控哪些数据源。" + }, + "ds_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "数据源 ID 列表,与 `ds_list` 合并后共同决定规则监控的数据源,使用 ID 可避免数据源改名后失效。`ds_list` 与 `ds_ids` 至少提供一个。" + }, + "enabled": { + "type": "boolean", + "description": "是否启用规则。必填,服务端解码时强制要求显式传入(包括 `false`)。更新为 `false` 时服务端会清理该规则的活跃告警。" + }, + "debug_log_enabled": { + "type": "boolean", + "description": "是否开启调试日志,开启后 edge 评估该规则时输出详细日志,用于排查规则未按预期触发等问题。" + }, + "rule_configs": { + "$ref": "#/components/schemas/AlertRuleConfigsV2", + "description": "检测配置,包含查询列表与触发/恢复条件,结构见 `AlertRuleConfigsV2`。" + }, + "cron_pattern": { + "type": "string", + "description": "调度表达式:6 段(含秒)cron 表达式或 `@every 30s` 间隔描述。不允许以 `CRON_TZ=` 或 `TZ=` 开头,时区请填写到 `timezone` 字段。" + }, + "timezone": { + "type": "string", + "default": "Asia/Shanghai", + "description": "告警规则执行时区,决定 cron 调度与生效时间窗口的解释方式。仅接受 IANA 时区名(如 `Asia/Shanghai`、`UTC`、`Europe/London`);不接受 `Local`、`UTC+8`、`CST` 等简写或偏移量。留空时按 `Asia/Shanghai` 处理。" + }, + "delay_seconds": { + "type": "integer", + "description": "评估时查询窗口向前偏移的秒数,用于补偿数据摄入延迟。" + }, + "enabled_times": { + "type": "array", + "description": "规则生效的时间窗口。省略或传空数组时,默认每天 00:00–23:59 生效。", + "default": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "items": { + "type": "object", + "properties": { + "days": { + "type": "array", + "items": { + "type": "integer" + }, + "description": "星期几(0=周日)。" + }, + "stime": { + "type": "string", + "description": "开始时间,如 `09:00`。" + }, + "etime": { + "type": "string", + "description": "结束时间,如 `18:00`。" + } + } + } + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "附加注解键值对,随告警事件下发;键不允许以 `$` 开头(该前缀保留给查询字段)。" + }, + "description_type": { + "type": "string", + "enum": [ + "text", + "markdown" + ], + "default": "text", + "description": "描述内容的格式。省略或为空时默认使用 `text`。`text` = 纯文本;`markdown` = Markdown 格式,告警详情中按 Markdown 渲染。" + }, + "description": { + "type": "string", + "description": "规则描述,Markdown 格式。" + }, + "channel_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "告警发送到的协作空间 ID 列表。可为空,告警将通过全局集成路由。" + }, + "repeat_interval": { + "type": "integer", + "format": "int64", + "description": "通知重复间隔(秒)。小于 1 时按默认值 3600 处理。" + }, + "repeat_total": { + "type": "integer", + "format": "int64", + "description": "最大重复通知次数。小于 1 时按默认值 3 处理。" + }, + "investigation_targets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InvestigationTarget" + }, + "description": "告警事件详情页关联的排障入口列表,最多 20 项,不允许重复。更新接口中该字段按 presence 处理:省略时保留原配置,传 `[]` 清空。", + "x-flashduty-preserve-absence": true + }, + "creator_id": { + "type": "integer", + "format": "uint64", + "description": "创建人 ID,由服务端按当前用户自动填充,客户端传入将被忽略。" + }, + "creator_name": { + "type": "string", + "description": "创建人名称,由服务端自动填充,客户端传入将被忽略。" + }, + "updater_id": { + "type": "integer", + "format": "uint64", + "description": "最近更新人 ID,由服务端自动填充,客户端传入将被忽略。" + }, + "updater_name": { + "type": "string", + "description": "最近更新人名称,由服务端自动填充,客户端传入将被忽略。" + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "创建时间,Unix 秒级时间戳,由服务端生成,客户端传入将被忽略。" + }, + "updated_at": { + "type": "integer", + "format": "int64", + "description": "最近更新时间,Unix 秒级时间戳,由服务端生成,客户端传入将被忽略。" + } + }, + "required": [ + "folder_id", + "name", + "ds_type", + "enabled", + "cron_pattern", + "rule_configs" + ] + }, + "AlertRuleConfigsV2": { + "type": "object", + "description": "V2 规则评估配置。", + "properties": { + "queries": { + "type": "array", + "description": "查询列表,至少一条;每条需唯一的 `name`(`R`、`__all__` 为保留名)与非空且不重复的 `expr`。", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "查询标识符(如 `A`),须匹配 `[A-Za-z][A-Za-z0-9_]*`;`R`、`__all__` 为保留名称,不可使用。" + }, + "expr": { + "type": "string", + "description": "查询表达式。" + }, + "label_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "作为告警事件标签的结果字段列表,相同标签组合归为同一告警;不可与 `value_fields` 重复,适用于表型结果(SQL/ES 等数据源)。" + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "参与阈值评估的数值结果字段列表(以 `$A.` 形式被阈值表达式引用);对阈值检查且数据源非 `prometheus`/`loki`/`victorialogs` 时必填,字段名不允许含 `.`。" + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "数据源相关的查询附加参数,键采用 `<数据源>.<参数>` 约定(如 `es.type`、`tencent_cls.limit`);大多数数据源无需配置。" + } + } + } + }, + "relate_queries": { + "type": "array", + "description": "可选的辅助查询,其结果作为上下文附加到告警事件中。每项须有唯一的 `name`(不与任何 query 名称重复)且 `expr` 非空。", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "辅助查询标识符。" + }, + "expr": { + "type": "string", + "description": "查询表达式。" + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "辅助查询的数据源相关附加参数,约定同 `queries[].args`。" + } + } + } + }, + "check_threshold": { + "$ref": "#/components/schemas/AlertRuleThresholdV2", + "description": "阈值检查配置,结构见 `AlertRuleThresholdV2`。" + }, + "check_anydata": { + "$ref": "#/components/schemas/AlertRuleAnyDataV2", + "description": "有数据检查配置:查询返回任意数据行时触发告警,结构见 `AlertRuleAnyDataV2`。" + }, + "check_nodata": { + "$ref": "#/components/schemas/AlertRuleNoDataV2", + "description": "无数据检查配置,结构见 `AlertRuleNoDataV2`。" + } + }, + "required": [ + "queries" + ] + }, + "AlertRuleThresholdV2": { + "type": "object", + "description": "阈值检查配置(lifecycle v2)。", + "properties": { + "enabled": { + "type": "boolean", + "description": "是否启用阈值检查。" + }, + "alerting_check_times": { + "type": "integer", + "description": "满足告警条件的次数达到该值后触发告警;启用时最小为 1、最大 10000。与 `alerting_window_size` 配合时表示最近 M 次评估中至少命中 N 次。" + }, + "alerting_window_size": { + "type": "integer", + "description": "可选的滑动窗口大小 M:最近 M 次评估中至少满足条件 `alerting_check_times` 次才触发。省略时为连续模式(连续 N 次命中)。取值须满足 `alerting_check_times` <= M <= 10000。" + }, + "recovery_check_times": { + "type": "integer", + "description": "满足恢复条件的次数达到该值后判定恢复,启用时最小为 1。" + }, + "critical": { + "type": "string", + "description": "Critical 级别阈值表达式,用 `$<查询名>` 或 `$<查询名>.` 引用查询结果,如 `$A > 90`;启用时三个级别至少配置一个。" + }, + "warning": { + "type": "string", + "description": "Warning 级别阈值表达式,语法同 `critical`。" + }, + "info": { + "type": "string", + "description": "Info 级别阈值表达式,语法同 `critical`。" + }, + "recovery_mode": { + "type": "string", + "enum": [ + "condition_clear", + "expression_match", + "recovery_query_match", + "manual" + ], + "description": "恢复判定方式(lifecycle v2),启用时必填。`condition_clear` = 告警表达式不再成立即恢复,不允许配置 `recovery`;`expression_match` = `recovery.expr` 阈值表达式成立时恢复;`recovery_query_match` = `recovery.expr` 查询表达式为真时恢复;`manual` = 不自动判定恢复,告警需人工处理,不推送恢复事件,不允许配置 `recovery`。" + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "恢复判定配置。仅 `recovery_mode` 为 `expression_match` 或 `recovery_query_match` 时必填(`recovery.expr` 非空),其余模式不允许传入。" + } + } + }, + "AlertRuleAnyDataV2": { + "type": "object", + "description": "有数据检查配置(lifecycle v2)。查询返回任意数据行时触发告警。", + "properties": { + "enabled": { + "type": "boolean", + "description": "是否启用有数据检查:查询返回任意数据行即触发告警。" + }, + "alerting_check_times": { + "type": "integer", + "description": "满足告警条件的次数达到该值后触发告警;启用时最小为 1、最大 10000。与 `alerting_window_size` 配合时表示最近 M 次评估中至少命中 N 次。" + }, + "alerting_window_size": { + "type": "integer", + "description": "可选的滑动窗口大小 M:最近 M 次评估中至少满足条件 `alerting_check_times` 次才触发。省略时为连续模式。取值须满足 `alerting_check_times` <= M <= 10000。" + }, + "recovery_check_times": { + "type": "integer", + "description": "满足恢复条件的次数达到该值后判定恢复,启用时最小为 1。" + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "有数据告警的事件级别,大小写敏感;启用时必填。" + }, + "recovery_mode": { + "type": "string", + "enum": [ + "data_absent", + "recovery_query_match", + "manual" + ], + "description": "恢复判定方式(lifecycle v2),启用时必填。`data_absent` = 查询无数据时恢复,不允许配置 `recovery`;`recovery_query_match` = `recovery.expr` 查询表达式为真时恢复,仅允许单个查询(`name=A`);`manual` = 不自动判定恢复,告警需人工处理,不推送恢复事件,不允许配置 `recovery`。" + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "恢复判定配置。仅 `recovery_mode` 为 `recovery_query_match` 时必填(`recovery.expr` 非空),其余模式不允许传入。" + } + } + }, + "AlertRuleNoDataV2": { + "type": "object", + "description": "无数据检查配置(lifecycle v2)。", + "properties": { + "enabled": { + "type": "boolean", + "description": "是否启用按序列的无数据检查:历史上有数据的序列查不到数据时触发告警。" + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "无数据告警的事件级别,大小写敏感;启用按序列检查时必填。" + }, + "alert_on_empty_result": { + "type": "boolean", + "description": "所有查询都返回空结果时是否触发告警(全局空结果检查)。" + }, + "alert_on_empty_result_severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "空结果告警的事件级别,大小写敏感;仅在 `alert_on_empty_result` 开启时生效且必填。" + }, + "alerting_check_times": { + "type": "integer", + "description": "满足告警条件的次数达到该值后触发告警;启用时最小为 1、最大 10000。与 `alerting_window_size` 配合时表示最近 M 次评估中至少命中 N 次。" + }, + "alerting_window_size": { + "type": "integer", + "description": "可选的滑动窗口大小 M:最近 M 次评估中至少满足条件 `alerting_check_times` 次才触发。省略时为连续模式。取值须满足 `alerting_check_times` <= M <= 10000。" + }, + "recovery_check_times": { + "type": "integer", + "description": "满足恢复条件的次数达到该值后判定恢复,启用时最小为 1。" + }, + "end_mode": { + "type": "string", + "enum": [ + "data_reappears", + "data_reappears_or_timeout", + "manual" + ], + "description": "无数据告警的结束方式(lifecycle v2),启用时必填。`data_reappears` = 数据重新出现时恢复;`data_reappears_or_timeout` = 数据重现或超过 `auto_close_after_seconds` 秒后自动关闭,要求启用按序列无数据检查且 `auto_close_after_seconds` 为正数;`manual` = 不自动结束,告警需人工处理,不推送恢复事件。`data_reappears` 和 `manual` 模式下 `auto_close_after_seconds` 必须为 0。" + }, + "auto_close_after_seconds": { + "type": "integer", + "format": "int64", + "description": "自动关闭等待时间(秒)。仅 `end_mode` 为 `data_reappears_or_timeout` 时允许且必须为正数,其余模式必须为 0。" + } + } + }, + "AlertRuleRecoveryQueryV2": { + "type": "object", + "description": "lifecycle v2 的恢复判定配置。", + "properties": { + "expr": { + "type": "string", + "description": "恢复条件表达式:`expression_match` 模式下为阈值表达式(如 `$A < 90`),`recovery_query_match` 模式下为查询表达式。启用对应模式时必填且非空。" + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "恢复表达式以 `$A.` 形式引用的数值结果字段,语义同查询的 `value_fields`。为空时不返回。" + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "恢复查询的数据源附加参数,键约定同查询的 `args`(`<数据源>.<参数>`)。为空时不返回。" + } + } + }, + "InvestigationTarget": { + "type": "object", + "description": "告警事件的关联排障入口,为封闭的 tagged union:新增类型需服务端显式支持。", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dashboard" + ], + "description": "排障入口类型,目前仅支持 `dashboard`。" + }, + "dashboard": { + "$ref": "#/components/schemas/DashboardInvestigationTarget", + "description": "`dashboard` 类型的入口配置;`kind` 为 `dashboard` 时必填。" + } + }, + "required": [ + "kind" + ] + }, + "DashboardInvestigationTarget": { + "type": "object", + "description": "dashboard 类型的排障入口配置。", + "properties": { + "dashboard_id": { + "type": "string", + "description": "目标仪表盘 ID,须为规范的 UUIDv7。" + }, + "target_id": { + "type": "string", + "description": "仪表盘内目标面板 ID,须为规范的 UUIDv7;可选。" + }, + "variable_bindings": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/InvestigationVariableBinding" + }, + "description": "仪表盘变量绑定,键为仪表盘变量名。" + } + }, + "required": [ + "dashboard_id" + ] + }, + "InvestigationVariableBinding": { + "type": "object", + "description": "仪表盘变量与告警事件数据的绑定。", + "properties": { + "source": { + "type": "string", + "enum": [ + "event_label" + ], + "description": "绑定值来源,目前仅支持 `event_label`(取告警事件的标签值)。" + }, + "key": { + "type": "string", + "description": "告警事件标签名,须符合 Prometheus 标签命名规则,且不能使用保留标签。" + } + }, + "required": [ + "source", + "key" + ] } } } diff --git a/api-reference/openapi.en.json b/api-reference/openapi.en.json index 2cb4760c..f49bc257 100644 --- a/api-reference/openapi.en.json +++ b/api-reference/openapi.en.json @@ -2057,7 +2057,7 @@ "type": "array" }, "ds_type": { - "description": "Datasource type identifier; allowed values are listed by `POST /monit/rule/dstypes` (e.g. `prometheus`, `elasticsearch`).", + "description": "Datasource type identifier (e.g. `prometheus`, `elasticsearch`).", "type": "string" }, "enabled": { @@ -2494,31 +2494,6 @@ }, "type": "array" }, - "AlertRuleInfoResponse": { - "allOf": [ - { - "$ref": "#/components/schemas/AlertRule" - } - ], - "description": "Full alert rule returned by the info endpoint. All server-assigned fields are guaranteed present.", - "required": [ - "id", - "account_id", - "folder_id", - "name", - "ds_type", - "enabled", - "debug_log_enabled", - "cron_pattern", - "delay_seconds", - "creator_id", - "creator_name", - "updater_id", - "updater_name", - "created_at", - "updated_at" - ] - }, "AlertShort": { "description": "Brief alert reference.", "properties": { @@ -7358,41 +7333,6 @@ ], "type": "object" }, - "DSType": { - "description": "A datasource type definition usable by alert rules.", - "properties": { - "account_id": { - "description": "Owning account ID. `0` for global types.", - "format": "uint64", - "type": "integer" - }, - "id": { - "description": "ID of the datasource type record.", - "format": "uint64", - "type": "integer" - }, - "ident": { - "description": "Identifier used as the `ds_type` of rules, e.g. `prometheus`.", - "type": "string" - }, - "name": { - "description": "Display name, e.g. `Prometheus`.", - "type": "string" - }, - "weight": { - "description": "Display order weight; higher appears first.", - "type": "integer" - } - }, - "required": [ - "id", - "name", - "ident", - "account_id", - "weight" - ], - "type": "object" - }, "DSVictoriaLogsConfig": { "description": "VictoriaLogs datasource configuration. TLS fields are inherited from TLSClientConfig.", "properties": { @@ -18489,14 +18429,6 @@ "description": "Map of channel name to rule count. Unresolved channel IDs appear as stringified IDs.", "type": "object" }, - "RuleCounterNodeResponse": { - "additionalProperties": { - "format": "int64", - "type": "integer" - }, - "description": "Map of top-level folder name to rule count.", - "type": "object" - }, "RuleCounterTotalResponse": { "description": "Historical rule-count samples ordered by `clock` ascending.", "items": { @@ -18522,13 +18454,6 @@ ], "type": "object" }, - "RuleDsTypesResponse": { - "description": "Datasource types available to the account — global types plus account-scoped types.", - "items": { - "$ref": "#/components/schemas/DSType" - }, - "type": "array" - }, "RuleEmptyRequest": { "additionalProperties": false, "description": "No parameters required.", @@ -18592,7 +18517,7 @@ "type": "array" }, "ds_type": { - "description": "Datasource type identifier; allowed values are listed by `POST /monit/rule/dstypes`. Effective only when `fields` includes `ds_type`.", + "description": "Datasource type identifier. Effective only when `fields` includes `ds_type`.", "type": "string" }, "enabled": { @@ -27888,6 +27813,525 @@ } }, "type": "object" + }, + "AlertRuleV2": { + "type": "object", + "description": "Complete V2 alert rule configuration. The core difference from V1 lives in `rule_configs`: the three checkers describe recovery and ending semantics with the lifecycle v2 `recovery_mode`/`end_mode` enums.", + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "description": "Rule ID. Required on update; omit on create (assigned by the server)." + }, + "account_id": { + "type": "integer", + "format": "uint64", + "description": "Account ID, filled by the server from the authentication context; any client-supplied value is ignored." + }, + "folder_id": { + "type": "integer", + "format": "uint64", + "description": "ID of the folder the rule belongs to; list folders via `POST /monit/folder/list`. Cannot be changed through the update API — use `/monit/rule/move` instead." + }, + "name": { + "type": "string", + "description": "Rule name. Must be unique within the folder and at most 128 characters." + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Custom labels." + }, + "ds_type": { + "type": "string", + "description": "Datasource type identifier (e.g. `prometheus`, `elasticsearch`)." + }, + "ds_list": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Datasource name match patterns (wildcards supported). At least one of `ds_list` / `ds_ids` must be non-empty; both are merged to decide which datasources the rule monitors." + }, + "ds_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "Datasource ID list, merged with `ds_list` to decide the monitored datasources; IDs survive datasource renames. At least one of `ds_list` / `ds_ids` must be provided." + }, + "enabled": { + "type": "boolean", + "description": "Whether the rule is enabled. Required — the server enforces an explicit value (including `false`) while decoding. Setting it to `false` on update clears the rule's active alerts." + }, + "debug_log_enabled": { + "type": "boolean", + "description": "Enable debug logging; the edge then emits detailed evaluation logs for this rule, useful when the rule does not trigger as expected." + }, + "rule_configs": { + "$ref": "#/components/schemas/AlertRuleConfigsV2", + "description": "Detection configuration: query list plus trigger/recovery conditions. See `AlertRuleConfigsV2`." + }, + "cron_pattern": { + "type": "string", + "description": "Schedule expression: a 6-field cron (with seconds) or an `@every 30s` interval. Must not start with `CRON_TZ=` or `TZ=`; set the timezone in the `timezone` field instead." + }, + "timezone": { + "type": "string", + "default": "Asia/Shanghai", + "description": "Timezone the rule runs in; it decides how the cron schedule and enabled time windows are interpreted. Only IANA names are accepted (e.g. `Asia/Shanghai`, `UTC`, `Europe/London`); abbreviations or offsets like `Local`, `UTC+8`, `CST` are rejected. Empty falls back to `Asia/Shanghai`." + }, + "delay_seconds": { + "type": "integer", + "description": "Seconds the evaluation query window is shifted back, compensating for data ingestion latency." + }, + "enabled_times": { + "type": "array", + "description": "Time windows during which the rule is in effect. When omitted or empty, the rule is active 00:00–23:59 every day.", + "default": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "items": { + "type": "object", + "properties": { + "days": { + "type": "array", + "items": { + "type": "integer" + }, + "description": "Days of week (0=Sunday)." + }, + "stime": { + "type": "string", + "description": "Start time, e.g. `09:00`." + }, + "etime": { + "type": "string", + "description": "End time, e.g. `18:00`." + } + } + } + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Extra annotation key-value pairs delivered with alert events; keys must not start with `$` (reserved for query fields)." + }, + "description_type": { + "type": "string", + "enum": [ + "text", + "markdown" + ], + "default": "text", + "description": "Format of the description content. Empty or omitted defaults to `text`. `text` = plain text; `markdown` = Markdown, rendered as such in alert details." + }, + "description": { + "type": "string", + "description": "Rule description, Markdown format." + }, + "channel_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "Collaboration space IDs alerts are sent to. May be empty; alerts then route through the global integration." + }, + "repeat_interval": { + "type": "integer", + "format": "int64", + "description": "Notification repeat interval in seconds. Values below 1 fall back to the default 3600." + }, + "repeat_total": { + "type": "integer", + "format": "int64", + "description": "Maximum number of repeat notifications. Values below 1 fall back to the default 3." + }, + "investigation_targets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InvestigationTarget" + }, + "description": "Drill-down entries linked from the alert event detail page; at most 20 items, duplicates rejected. On update the field is presence-based: omit it to keep the current value, pass `[]` to clear.", + "x-flashduty-preserve-absence": true + }, + "creator_id": { + "type": "integer", + "format": "uint64", + "description": "Creator member ID, filled by the server from the current user; any client-supplied value is ignored." + }, + "creator_name": { + "type": "string", + "description": "Creator name, filled by the server; any client-supplied value is ignored." + }, + "updater_id": { + "type": "integer", + "format": "uint64", + "description": "ID of the member who last updated the rule, filled by the server; any client-supplied value is ignored." + }, + "updater_name": { + "type": "string", + "description": "Name of the member who last updated the rule, filled by the server; any client-supplied value is ignored." + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "Creation time as a Unix timestamp in seconds, generated by the server; any client-supplied value is ignored." + }, + "updated_at": { + "type": "integer", + "format": "int64", + "description": "Last update time as a Unix timestamp in seconds, generated by the server; any client-supplied value is ignored." + } + }, + "required": [ + "folder_id", + "name", + "ds_type", + "enabled", + "cron_pattern", + "rule_configs" + ] + }, + "AlertRuleConfigsV2": { + "type": "object", + "description": "V2 rule evaluation configuration.", + "properties": { + "queries": { + "type": "array", + "description": "Query list with at least one entry; each needs a unique `name` (`R` and `__all__` are reserved) and a non-empty, non-duplicated `expr`.", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Query identifier (e.g. `A`), must match `[A-Za-z][A-Za-z0-9_]*`; `R` and `__all__` are reserved and cannot be used." + }, + "expr": { + "type": "string", + "description": "Query expression." + }, + "label_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Result fields used as alert event labels; rows with the same label set form one alert. Must not overlap `value_fields`; applies to tabular results (SQL/ES-like datasources)." + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Numeric result fields evaluated by threshold expressions (referenced as `$A.`); required for threshold checks when the datasource is not `prometheus`/`loki`/`victorialogs`. Field names must not contain `.`." + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Datasource-specific query parameters; keys follow the `.` convention (e.g. `es.type`, `tencent_cls.limit`). Most datasources need none." + } + } + } + }, + "relate_queries": { + "type": "array", + "description": "Optional auxiliary queries whose results attach to alert events as context. Each entry needs a unique `name` (not colliding with any query name) and a non-empty `expr`.", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "Auxiliary query identifier." + }, + "expr": { + "type": "string", + "description": "Query expression." + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Datasource-specific parameters for the auxiliary query; same convention as `queries[].args`." + } + } + } + }, + "check_threshold": { + "$ref": "#/components/schemas/AlertRuleThresholdV2", + "description": "Threshold check configuration. See `AlertRuleThresholdV2`." + }, + "check_anydata": { + "$ref": "#/components/schemas/AlertRuleAnyDataV2", + "description": "Any-data check configuration: fires when a query returns any data row. See `AlertRuleAnyDataV2`." + }, + "check_nodata": { + "$ref": "#/components/schemas/AlertRuleNoDataV2", + "description": "No-data check configuration. See `AlertRuleNoDataV2`." + } + }, + "required": [ + "queries" + ] + }, + "AlertRuleThresholdV2": { + "type": "object", + "description": "Threshold check configuration (lifecycle v2).", + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether the threshold check is enabled." + }, + "alerting_check_times": { + "type": "integer", + "description": "Fire after the alert condition is met this many times; when enabled, minimum 1 and maximum 10000. Combined with `alerting_window_size` it means at least N hits within the last M evaluations." + }, + "alerting_window_size": { + "type": "integer", + "description": "Optional sliding window size M: fire only when the condition is met at least `alerting_check_times` times within the last M evaluations. Omit for consecutive mode (N consecutive hits). Must satisfy `alerting_check_times` <= M <= 10000." + }, + "recovery_check_times": { + "type": "integer", + "description": "Recover after the recovery condition is met this many times; minimum 1 when enabled." + }, + "critical": { + "type": "string", + "description": "Critical threshold expression referencing query results as `$` or `$.`, e.g. `$A > 90`; when enabled at least one of the three severities must be set." + }, + "warning": { + "type": "string", + "description": "Warning threshold expression; same syntax as `critical`." + }, + "info": { + "type": "string", + "description": "Info threshold expression; same syntax as `critical`." + }, + "recovery_mode": { + "type": "string", + "enum": [ + "condition_clear", + "expression_match", + "recovery_query_match", + "manual" + ], + "description": "How recovery is decided (lifecycle v2); required when enabled. `condition_clear` = recover once the alert expression no longer holds; `recovery` is not allowed. `expression_match` = recover when the `recovery.expr` threshold expression holds. `recovery_query_match` = recover when the `recovery.expr` query expression evaluates true. `manual` = never recover automatically; alerts need manual handling, no recovery event is pushed, and `recovery` is not allowed." + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "Recovery evaluation config. Required (with non-empty `recovery.expr`) only when `recovery_mode` is `expression_match` or `recovery_query_match`; must be omitted for the other modes." + } + } + }, + "AlertRuleAnyDataV2": { + "type": "object", + "description": "Any-data check configuration (lifecycle v2). Fires when a query returns any data row.", + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether the any-data check is enabled: any returned data row triggers an alert." + }, + "alerting_check_times": { + "type": "integer", + "description": "Fire after the alert condition is met this many times; when enabled, minimum 1 and maximum 10000. Combined with `alerting_window_size` it means at least N hits within the last M evaluations." + }, + "alerting_window_size": { + "type": "integer", + "description": "Optional sliding window size M: fire only when the condition is met at least `alerting_check_times` times within the last M evaluations. Omit for consecutive mode. Must satisfy `alerting_check_times` <= M <= 10000." + }, + "recovery_check_times": { + "type": "integer", + "description": "Recover after the recovery condition is met this many times; minimum 1 when enabled." + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "Severity of any-data alerts, case-sensitive; required when enabled." + }, + "recovery_mode": { + "type": "string", + "enum": [ + "data_absent", + "recovery_query_match", + "manual" + ], + "description": "How recovery is decided (lifecycle v2); required when enabled. `data_absent` = recover when the query returns no data; `recovery` is not allowed. `recovery_query_match` = recover when the `recovery.expr` query expression evaluates true; only a single query (`name=A`) is allowed. `manual` = never recover automatically; alerts need manual handling, no recovery event is pushed, and `recovery` is not allowed." + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "Recovery evaluation config. Required (with non-empty `recovery.expr`) only when `recovery_mode` is `recovery_query_match`; must be omitted for the other modes." + } + } + }, + "AlertRuleNoDataV2": { + "type": "object", + "description": "No-data check configuration (lifecycle v2).", + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether the per-series no-data check is enabled: series that previously reported data trigger an alert when data disappears." + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "Severity of no-data alerts, case-sensitive; required when the per-series check is enabled." + }, + "alert_on_empty_result": { + "type": "boolean", + "description": "Whether to alert when all queries return empty results (global empty-result check)." + }, + "alert_on_empty_result_severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "Severity of empty-result alerts, case-sensitive; only takes effect and is required when `alert_on_empty_result` is on." + }, + "alerting_check_times": { + "type": "integer", + "description": "Fire after the alert condition is met this many times; when enabled, minimum 1 and maximum 10000. Combined with `alerting_window_size` it means at least N hits within the last M evaluations." + }, + "alerting_window_size": { + "type": "integer", + "description": "Optional sliding window size M: fire only when the condition is met at least `alerting_check_times` times within the last M evaluations. Omit for consecutive mode. Must satisfy `alerting_check_times` <= M <= 10000." + }, + "recovery_check_times": { + "type": "integer", + "description": "Recover after the recovery condition is met this many times; minimum 1 when enabled." + }, + "end_mode": { + "type": "string", + "enum": [ + "data_reappears", + "data_reappears_or_timeout", + "manual" + ], + "description": "How a no-data alert ends (lifecycle v2); required when enabled. `data_reappears` = recover when data reappears. `data_reappears_or_timeout` = end when data reappears or after `auto_close_after_seconds` seconds, whichever comes first; requires the per-series no-data check and a positive `auto_close_after_seconds`. `manual` = never end automatically; alerts need manual handling and no recovery event is pushed. For `data_reappears` and `manual`, `auto_close_after_seconds` must be 0." + }, + "auto_close_after_seconds": { + "type": "integer", + "format": "int64", + "description": "Seconds to wait before auto-closing. Allowed and required to be positive only when `end_mode` is `data_reappears_or_timeout`; must be 0 for the other modes." + } + } + }, + "AlertRuleRecoveryQueryV2": { + "type": "object", + "description": "Recovery evaluation configuration for lifecycle v2.", + "properties": { + "expr": { + "type": "string", + "description": "Recovery condition expression: a threshold expression (e.g. `$A < 90`) in `expression_match` mode, a query expression in `recovery_query_match` mode. Required and non-empty when the corresponding mode is enabled." + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Numeric result fields the recovery expression references as `$A.`; same semantics as a query's `value_fields`. Not returned when empty." + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "Datasource-specific parameters for the recovery query; keys follow the same `.` convention as a query's `args`. Not returned when empty." + } + } + }, + "InvestigationTarget": { + "type": "object", + "description": "Drill-down entry linked to alert events. A deliberately closed tagged union: new kinds require explicit server support.", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dashboard" + ], + "description": "Entry type; currently only `dashboard` is supported." + }, + "dashboard": { + "$ref": "#/components/schemas/DashboardInvestigationTarget", + "description": "Configuration for the `dashboard` kind; required when `kind` is `dashboard`." + } + }, + "required": [ + "kind" + ] + }, + "DashboardInvestigationTarget": { + "type": "object", + "description": "Configuration of a dashboard drill-down entry.", + "properties": { + "dashboard_id": { + "type": "string", + "description": "Target dashboard ID; must be a canonical UUIDv7." + }, + "target_id": { + "type": "string", + "description": "Panel ID inside the dashboard; must be a canonical UUIDv7. Optional." + }, + "variable_bindings": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/InvestigationVariableBinding" + }, + "description": "Dashboard variable bindings, keyed by dashboard variable name." + } + }, + "required": [ + "dashboard_id" + ] + }, + "InvestigationVariableBinding": { + "type": "object", + "description": "Binding between a dashboard variable and alert event data.", + "properties": { + "source": { + "type": "string", + "enum": [ + "event_label" + ], + "description": "Where the bound value comes from; currently only `event_label` (the alert event's label value) is supported." + }, + "key": { + "type": "string", + "description": "Alert event label name; must follow Prometheus label naming rules and must not be a reserved label." + } + }, + "required": [ + "source", + "key" + ] } }, "securitySchemes": { @@ -42237,77 +42681,6 @@ } } }, - "/monit/rule/counter/node": { - "post": { - "description": "Return an object mapping top-level folder name to the total number of rules under that folder and all its descendants.", - "operationId": "monit-rule-read-counter-node", - "requestBody": { - "content": { - "application/json": { - "example": {}, - "schema": { - "$ref": "#/components/schemas/RuleEmptyRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "content": { - "application/json": { - "example": { - "data": { - "Production": 10, - "Staging": 3 - }, - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "properties": { - "data": { - "$ref": "#/components/schemas/RuleCounterNodeResponse" - } - }, - "type": "object" - } - ] - } - } - }, - "description": "Success" - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "summary": "Get rule counts by folder node", - "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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-counter-node", - "metadata": { - "sidebarTitle": "Get rule counts by folder node" - } - } - } - }, "/monit/rule/counter/total": { "post": { "description": "Return the stored time series of the total rule count across the account — one sample per `clock` timestamp.", @@ -42383,46 +42756,18 @@ } } }, - "/monit/rule/create": { + "/monit/rule/delete": { "post": { - "description": "Create a new alert rule. Returns the created rule with its assigned ID.", - "operationId": "monit-rule-write-create", + "description": "Delete a single alert rule by its ID.", + "operationId": "monit-rule-write-delete", "requestBody": { "content": { "application/json": { "example": { - "channel_ids": [ - 20001 - ], - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "name": "CPU High", - "rule_configs": { - "check_threshold": { - "alerting_check_times": 1, - "critical": "A", - "enabled": true, - "push_recovery_event": true, - "recovery": { - "mode": "invert" - }, - "recovery_check_times": 1 - }, - "queries": [ - { - "expr": "avg(cpu_usage_idle) < 10", - "name": "A" - } - ] - } + "id": 50001 }, "schema": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleIDRequest" } } }, @@ -42433,13 +42778,7 @@ "content": { "application/json": { "example": { - "data": { - "created_at": 1712000000, - "ds_type": "prometheus", - "folder_id": 100, - "id": 50001, - "name": "CPU High" - }, + "data": {}, "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" }, "schema": { @@ -42450,7 +42789,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleEmptyResponse" } }, "type": "object" @@ -42474,31 +42813,34 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Create alert rule", + "summary": "Delete alert rule", "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- `name`, `ds_type`, `cron_pattern`, and `rule_configs.queries` are required.\n- Either `ds_list` (supports wildcards) or `ds_ids` must be non-empty.\n- `cron_pattern` uses standard 5-field cron syntax.\n- `channel_ids` can be empty; alerts will then route through the global integration.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-create", + "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- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete", "metadata": { - "sidebarTitle": "Create alert rule" + "sidebarTitle": "Delete alert rule" } } } }, - "/monit/rule/delete": { + "/monit/rule/delete/batch": { "post": { - "description": "Delete a single alert rule by its ID.", - "operationId": "monit-rule-write-delete", + "description": "Delete multiple alert rules in a single request.", + "operationId": "monit-rule-write-delete-batch", "requestBody": { "content": { "application/json": { "example": { - "id": 50001 + "ids": [ + 50001, + 50002 + ] }, "schema": { - "$ref": "#/components/schemas/RuleIDRequest" + "$ref": "#/components/schemas/RuleIDsRequest" } } }, @@ -42544,30 +42886,29 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Delete alert rule", + "summary": "Batch delete alert rules", "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- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **30 requests/minute**; **5 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete-batch", "metadata": { - "sidebarTitle": "Delete alert rule" + "sidebarTitle": "Batch delete alert rules" } } } }, - "/monit/rule/delete/batch": { + "/monit/rule/export": { "post": { - "description": "Delete multiple alert rules in a single request.", - "operationId": "monit-rule-write-delete-batch", + "description": "Export the configuration of selected alert rules as a portable JSON array, compatible with `POST /monit/rule/import`.", + "operationId": "monit-rule-read-export", "requestBody": { "content": { "application/json": { "example": { "ids": [ - 50001, - 50002 + 50001 ] }, "schema": { @@ -42582,7 +42923,17 @@ "content": { "application/json": { "example": { - "data": {}, + "data": [ + { + "cron_pattern": "0 * * * * *", + "ds_list": [ + "prometheus*" + ], + "ds_type": "prometheus", + "enabled": true, + "name": "CPU High" + } + ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" }, "schema": { @@ -42593,7 +42944,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/RuleEmptyResponse" + "$ref": "#/components/schemas/AlertRuleExportListResponse" } }, "type": "object" @@ -42617,29 +42968,48 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Batch delete alert rules", + "summary": "Export alert rules", "tags": [ "Monitors/Alert rules" ], "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **30 requests/minute**; **5 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-delete-batch", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/day**; **200 requests/minute**; **20 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-export", "metadata": { - "sidebarTitle": "Batch delete alert rules" + "sidebarTitle": "Export alert rules" } } } }, - "/monit/rule/dstypes": { + "/monit/rule/import": { "post": { - "description": "Return the list of datasource types (`DSType` records) that the current account can use when authoring alert rules — combines global types and account-scoped types.", - "operationId": "monit-rule-read-dstypes", + "description": "Import one or more alert rules from a JSON array. Returns the result for each rule, indicating success or failure.", + "operationId": "monit-rule-write-import", "requestBody": { "content": { "application/json": { - "example": {}, + "example": [ + { + "cron_pattern": "0 * * * * *", + "ds_list": [ + "prometheus*" + ], + "ds_type": "prometheus", + "enabled": true, + "folder_id": 100, + "name": "CPU High", + "rule_configs": { + "queries": [ + { + "expr": "avg(cpu_usage_idle) < 10", + "name": "A" + } + ] + } + } + ], "schema": { - "$ref": "#/components/schemas/RuleEmptyRequest" + "$ref": "#/components/schemas/RuleImportRequest" } } }, @@ -42652,11 +43022,8 @@ "example": { "data": [ { - "account_id": 0, - "id": 1, - "ident": "prometheus", - "name": "Prometheus", - "weight": 100 + "message": "", + "name": "CPU High" } ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" @@ -42669,7 +43036,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/RuleDsTypesResponse" + "$ref": "#/components/schemas/RuleImportResponse" } }, "type": "object" @@ -42693,33 +43060,31 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "List available datasource types", + "summary": "Import alert rules", "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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-dstypes", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **20 requests/minute**; **2 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- The request body is a JSON array of rule export objects (compatible with the output of `POST /monit/rule/export`).\n- Each object must include `folder_id`, `ds_type`, and either `ds_list` or `ds_ids`.\n- Some rules may fail (e.g. duplicate name). Check each result for individual status.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-import", "metadata": { - "sidebarTitle": "List available datasource types" + "sidebarTitle": "Import alert rules" } } } }, - "/monit/rule/export": { + "/monit/rule/list/basic": { "post": { - "description": "Export the configuration of selected alert rules as a portable JSON array, compatible with `POST /monit/rule/import`.", - "operationId": "monit-rule-read-export", + "description": "Return the basic information of all alert rules in a folder. For full rule details, call `POST /monit/rule/v2/info`.", + "operationId": "monit-rule-read-list", "requestBody": { "content": { "application/json": { "example": { - "ids": [ - 50001 - ] + "folder_id": 100 }, "schema": { - "$ref": "#/components/schemas/RuleIDsRequest" + "$ref": "#/components/schemas/RuleListRequest" } } }, @@ -42732,13 +43097,15 @@ "example": { "data": [ { - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], + "active_alert_count": 2, + "created_at": 1710000000, "ds_type": "prometheus", "enabled": true, - "name": "CPU High" + "folder_id": 100, + "id": 50001, + "name": "CPU High", + "runtime_state": "normal", + "triggered": true } ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" @@ -42751,7 +43118,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/AlertRuleExportListResponse" + "$ref": "#/components/schemas/RuleBasicListResponse" } }, "type": "object" @@ -42775,48 +43142,35 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Export alert rules", + "summary": "List alert rules", "tags": [ "Monitors/Alert rules" ], "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/day**; **200 requests/minute**; **20 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-export", + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **1,000 requests/minute**; **50 requests/second** per account |\n| Permissions | **Alerting Rules Read** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to list all rules across all folders visible to the current user.\n- The `triggered` field indicates whether the rule has any currently active alerts.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-list", "metadata": { - "sidebarTitle": "Export alert rules" + "sidebarTitle": "List alert rules" } } } }, - "/monit/rule/import": { + "/monit/rule/move": { "post": { - "description": "Import one or more alert rules from a JSON array. Returns the result for each rule, indicating success or failure.", - "operationId": "monit-rule-write-import", + "description": "Move one or more alert rules to a different folder.", + "operationId": "monit-rule-write-move", "requestBody": { "content": { "application/json": { - "example": [ - { - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "name": "CPU High", - "rule_configs": { - "queries": [ - { - "expr": "avg(cpu_usage_idle) < 10", - "name": "A" - } - ] - } - } - ], + "example": { + "dest_folder_id": 200, + "ids": [ + 50001, + 50002 + ] + }, "schema": { - "$ref": "#/components/schemas/RuleImportRequest" + "$ref": "#/components/schemas/RuleMoveRequest" } } }, @@ -42843,7 +43197,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/RuleImportResponse" + "$ref": "#/components/schemas/RuleNameMessageListResponse" } }, "type": "object" @@ -42867,31 +43221,38 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Import alert rules", + "summary": "Move alert rules to folder", "tags": [ "Monitors/Alert rules" ], "x-mint": { - "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **20 requests/minute**; **2 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- The request body is a JSON array of rule export objects (compatible with the output of `POST /monit/rule/export`).\n- Each object must include `folder_id`, `ds_type`, and either `ds_list` or `ds_ids`.\n- Some rules may fail (e.g. duplicate name). Check each result for individual status.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-import", + "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- Rules whose names already exist in the destination folder are skipped. Inspect each result's `message` to identify conflicts.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-move", "metadata": { - "sidebarTitle": "Import alert rules" + "sidebarTitle": "Move alert rules to folder" } } } }, - "/monit/rule/info": { + "/monit/rule/update/fields": { "post": { - "description": "Return the full configuration of an alert rule by its ID, including rule queries, thresholds, and notification settings.", - "operationId": "monit-rule-read-info", + "description": "Update specific fields across multiple alert rules at once. Only the fields listed in `fields` are applied.", + "operationId": "monit-rule-write-fields-update", "requestBody": { "content": { "application/json": { "example": { - "id": 50001 + "enabled": false, + "fields": [ + "enabled" + ], + "ids": [ + 50001, + 50002 + ] }, "schema": { - "$ref": "#/components/schemas/RuleIDRequest" + "$ref": "#/components/schemas/RuleFieldsUpdateRequest" } } }, @@ -42902,20 +43263,16 @@ "content": { "application/json": { "example": { - "data": { - "channel_ids": [ - 20001 - ], - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "id": 50001, - "name": "CPU High" - }, + "data": [ + { + "message": "", + "name": "CPU High" + }, + { + "message": "", + "name": "Disk High" + } + ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" }, "schema": { @@ -42926,7 +43283,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/AlertRuleInfoResponse" + "$ref": "#/components/schemas/RuleNameMessageListResponse" } }, "type": "object" @@ -42950,74 +43307,123 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Get alert rule detail", + "summary": "Batch update rule fields", "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 Read** (`monit`) |", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-info", + "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- Include the field names you want to update in the `fields` array, e.g. `[\"enabled\", \"channel_ids\"]`.\n- Only the specified fields are updated; others are left unchanged.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-fields-update", "metadata": { - "sidebarTitle": "Get alert rule detail" + "sidebarTitle": "Batch update rule fields" } } } }, - "/monit/rule/list/basic": { + "/monit/rule/v2/info": { "post": { - "description": "Return the basic information of all alert rules in a folder. For full rule details, call `POST /monit/rule/info`.", - "operationId": "monit-rule-read-list", - "requestBody": { - "content": { - "application/json": { - "example": { - "folder_id": 100 - }, - "schema": { - "$ref": "#/components/schemas/RuleListRequest" - } - } - }, - "required": true + "operationId": "monit-rule-read-info-v2", + "summary": "Get alert rule detail (V2)", + "description": "Return the full V2 configuration of an alert rule by ID, including lifecycle v2 recovery and ending modes.", + "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 Read** (`monit`) |\n\n## Usage\n\n- `id` is required and must not be `0`; otherwise the call returns `InvalidParameter`.\n- A missing rule returns `InvalidParameter` (`alert rule not found`).", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-info-v2", + "metadata": { + "sidebarTitle": "Get alert rule detail (V2)" + } }, "responses": { "200": { + "description": "Success", "content": { "application/json": { - "example": { - "data": [ - { - "active_alert_count": 2, - "created_at": 1710000000, - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "id": 50001, - "name": "CPU High", - "runtime_state": "normal", - "triggered": true - } - ], - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, "schema": { "allOf": [ { "$ref": "#/components/schemas/SuccessEnvelope" }, { + "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleBasicListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } - }, - "type": "object" + } } ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } - }, - "description": "Success" + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -43032,71 +43438,125 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "List alert rules", - "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 Read** (`monit`) |\n\n## Usage\n\n- Set `folder_id` to `0` to list all rules across all folders visible to the current user.\n- The `triggered` field indicates whether the rule has any currently active alerts.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-read-list", - "metadata": { - "sidebarTitle": "List alert rules" - } - } - } - }, - "/monit/rule/move": { - "post": { - "description": "Move one or more alert rules to a different folder.", - "operationId": "monit-rule-write-move", "requestBody": { + "required": true, "content": { "application/json": { - "example": { - "dest_folder_id": 200, - "ids": [ - 50001, - 50002 - ] - }, "schema": { - "$ref": "#/components/schemas/RuleMoveRequest" + "$ref": "#/components/schemas/RuleIDRequest" + }, + "example": { + "id": 50001 } } - }, - "required": true + } + } + } + }, + "/monit/rule/v2/create": { + "post": { + "operationId": "monit-rule-write-create-v2", + "summary": "Create alert rule (V2)", + "description": "Create a new V2 alert rule. Returns the created rule with its assigned ID.", + "tags": [ + "Monitors/Alert rules" + ], + "x-mint": { + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **300 requests/minute**; **20 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- `name`, `ds_type`, `enabled`, `cron_pattern`, and `rule_configs.queries` are required; either `ds_list` (supports wildcards) or `ds_ids` must be non-empty.\n- `enabled` must be passed explicitly (including `false`); omitting it returns `InvalidParameter`.\n- `id`, `account_id`, `creator_*`, `updater_*`, `created_at`, and `updated_at` are assigned by the server; client-supplied values are ignored.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- `channel_ids` can be empty; alerts will then route through the global integration.\n- The request body tolerates additional unknown fields (forward compatibility); they are ignored.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-create-v2", + "metadata": { + "sidebarTitle": "Create alert rule (V2)" + } }, "responses": { "200": { + "description": "Success", "content": { "application/json": { - "example": { - "data": [ - { - "message": "", - "name": "CPU High" - } - ], - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, "schema": { "allOf": [ { "$ref": "#/components/schemas/SuccessEnvelope" }, { + "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleNameMessageListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } - }, - "type": "object" + } } ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } - }, - "description": "Success" + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -43111,81 +43571,152 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Move alert rules to folder", - "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- Rules whose names already exist in the destination folder are skipped. Inspect each result's `message` to identify conflicts.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-move", - "metadata": { - "sidebarTitle": "Move alert rules to folder" - } - } - } - }, - "/monit/rule/update": { - "post": { - "description": "Replace the full configuration of an existing alert rule. All fields are overwritten.", - "operationId": "monit-rule-write-update", "requestBody": { + "required": true, "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/AlertRuleV2" + }, "example": { - "cron_pattern": "0 * * * * *", + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", "ds_list": [ "prometheus*" ], - "ds_type": "prometheus", "enabled": true, - "folder_id": 100, - "id": 50001, - "name": "CPU High v2", + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 + ], "rule_configs": { "queries": [ { - "expr": "avg(cpu_usage_idle) < 5", - "name": "A" + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" } - ] + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } } - }, - "schema": { - "$ref": "#/components/schemas/AlertRule" } } - }, - "required": true + } + } + } + }, + "/monit/rule/v2/update": { + "post": { + "operationId": "monit-rule-write-update-v2", + "summary": "Update alert rule (V2)", + "description": "Replace an alert rule's V2 configuration in full by ID. Returns the updated rule.", + "tags": [ + "Monitors/Alert rules" + ], + "x-mint": { + "content": "## Restrictions\n\n| Aspect | Value |\n| ------ | ----- |\n| Rate limits | **300 requests/minute**; **20 requests/second** per account |\n| Permissions | **Alerting Rules Manage** (`monit`) |\n\n## Usage\n\n- `id` is required and the rule must already exist; otherwise the call returns `InvalidParameter`.\n- This is a full-field replacement: except for the cases below, fields you omit are stored as zero values. Fetch the full configuration via `/monit/rule/v2/info` before modifying it.\n- `enabled` must be passed explicitly (including `false`); omitting it returns `InvalidParameter`. Setting it to `false` clears the rule's active alerts.\n- `investigation_targets` is the exception: omit it to keep the current value, pass `[]` to clear, or pass a value to replace it entirely.\n- `folder_id` cannot be changed through this operation; use `/monit/rule/move` to move the rule to another folder.\n- `account_id`, `creator_*`, `updater_*`, `created_at`, and `updated_at` are maintained by the server; client-supplied values are ignored.\n- `name` must be unique within `folder_id`; a duplicate returns `InvalidParameter`.\n- The request body tolerates additional unknown fields (forward compatibility); they are ignored.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", + "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-update-v2", + "metadata": { + "sidebarTitle": "Update alert rule (V2)" + } }, "responses": { "200": { + "description": "Success", "content": { "application/json": { - "example": { - "data": { - "id": 50001, - "updated_at": 1712100000 - }, - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, "schema": { "allOf": [ { "$ref": "#/components/schemas/SuccessEnvelope" }, { + "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/AlertRuleV2" } - }, - "type": "object" + } } ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712003600 + } } } - }, - "description": "Success" + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -43200,101 +43731,45 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "Update alert rule", - "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- `id` is required. All other fields follow the same rules as `POST /monit/rule/create`.\n- The name must remain unique within its folder; a duplicate returns `InvalidParameter`.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-update", - "metadata": { - "sidebarTitle": "Update alert rule" - } - } - } - }, - "/monit/rule/update/fields": { - "post": { - "description": "Update specific fields across multiple alert rules at once. Only the fields listed in `fields` are applied.", - "operationId": "monit-rule-write-fields-update", "requestBody": { + "required": true, "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/AlertRuleV2" + }, "example": { - "enabled": false, - "fields": [ - "enabled" + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" ], - "ids": [ - 50001, - 50002 - ] - }, - "schema": { - "$ref": "#/components/schemas/RuleFieldsUpdateRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "content": { - "application/json": { - "example": { - "data": [ - { - "message": "", - "name": "CPU High" - }, + "enabled": true, + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 + ], + "rule_configs": { + "queries": [ { - "message": "", - "name": "Disk High" + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" } ], - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } }, - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "properties": { - "data": { - "$ref": "#/components/schemas/RuleNameMessageListResponse" - } - }, - "type": "object" - } - ] - } + "id": 50001 } - }, - "description": "Success" - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "summary": "Batch update rule fields", - "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- Include the field names you want to update in the `fields` array, e.g. `[\"enabled\", \"channel_ids\"]`.\n- Only the specified fields are updated; others are left unchanged.\n- Every call is recorded in the account audit log. Don't put secrets in request fields.", - "href": "/en/api-reference/monitors/alert-rules/monit-rule-write-fields-update", - "metadata": { - "sidebarTitle": "Batch update rule fields" + } } } } diff --git a/api-reference/openapi.zh.json b/api-reference/openapi.zh.json index 69393af0..338f1325 100644 --- a/api-reference/openapi.zh.json +++ b/api-reference/openapi.zh.json @@ -2057,7 +2057,7 @@ "type": "array" }, "ds_type": { - "description": "数据源类型标识,可选值可通过 `POST /monit/rule/dstypes` 查询(如 `prometheus`、`elasticsearch`)。", + "description": "数据源类型标识(如 `prometheus`、`elasticsearch`)。", "type": "string" }, "enabled": { @@ -2494,31 +2494,6 @@ }, "type": "array" }, - "AlertRuleInfoResponse": { - "allOf": [ - { - "$ref": "#/components/schemas/AlertRule" - } - ], - "description": "info 接口返回的完整告警规则,服务端赋值字段均保证存在。", - "required": [ - "id", - "account_id", - "folder_id", - "name", - "ds_type", - "enabled", - "debug_log_enabled", - "cron_pattern", - "delay_seconds", - "creator_id", - "creator_name", - "updater_id", - "updater_name", - "created_at", - "updated_at" - ] - }, "AlertShort": { "description": "告警简要引用。", "properties": { @@ -7358,41 +7333,6 @@ ], "type": "object" }, - "DSType": { - "description": "告警规则可使用的数据源类型定义。", - "properties": { - "account_id": { - "description": "所属账户 ID;`0` 表示全局类型。", - "format": "uint64", - "type": "integer" - }, - "id": { - "description": "数据源类型记录 ID。", - "format": "uint64", - "type": "integer" - }, - "ident": { - "description": "作为规则 `ds_type` 的标识符,如 `prometheus`。", - "type": "string" - }, - "name": { - "description": "显示名称,如 `Prometheus`。", - "type": "string" - }, - "weight": { - "description": "排序权重,值越大越靠前。", - "type": "integer" - } - }, - "required": [ - "id", - "name", - "ident", - "account_id", - "weight" - ], - "type": "object" - }, "DSVictoriaLogsConfig": { "description": "VictoriaLogs 数据源配置,TLS 字段继承自 TLSClientConfig。", "properties": { @@ -18489,14 +18429,6 @@ "description": "协作空间名称到规则数量的映射,无法解析的协作空间以其 ID 的字符串形式作为 key。", "type": "object" }, - "RuleCounterNodeResponse": { - "additionalProperties": { - "format": "int64", - "type": "integer" - }, - "description": "顶层文件夹名称到规则数量的映射。", - "type": "object" - }, "RuleCounterTotalResponse": { "description": "按 `clock` 升序排列的规则数量历史采样。", "items": { @@ -18522,13 +18454,6 @@ ], "type": "object" }, - "RuleDsTypesResponse": { - "description": "当前账户可使用的数据源类型列表,包括全局类型和账户自定义类型。", - "items": { - "$ref": "#/components/schemas/DSType" - }, - "type": "array" - }, "RuleEmptyRequest": { "additionalProperties": false, "description": "不需要任何参数。", @@ -18592,7 +18517,7 @@ "type": "array" }, "ds_type": { - "description": "数据源类型标识,可选值可通过 `POST /monit/rule/dstypes` 查询。仅当 `fields` 包含 `ds_type` 时生效。", + "description": "数据源类型标识。仅当 `fields` 包含 `ds_type` 时生效。", "type": "string" }, "enabled": { @@ -27888,6 +27813,525 @@ } }, "type": "object" + }, + "AlertRuleV2": { + "type": "object", + "description": "完整的 V2 告警规则配置。与 V1 的核心差异在 `rule_configs`:三个检查器使用 lifecycle v2 的 `recovery_mode`/`end_mode` 枚举描述恢复与结束语义。", + "properties": { + "id": { + "type": "integer", + "format": "uint64", + "description": "规则 ID。更新时必填,创建时省略(服务端自动分配)。" + }, + "account_id": { + "type": "integer", + "format": "uint64", + "description": "账户 ID,由服务端按认证信息自动填充,客户端传入将被忽略。" + }, + "folder_id": { + "type": "integer", + "format": "uint64", + "description": "规则所属文件夹 ID,可通过 `POST /monit/folder/list` 获取。创建后不可通过更新接口修改,调整文件夹请使用 `/monit/rule/move`。" + }, + "name": { + "type": "string", + "description": "规则名称,同一文件夹内必须唯一,最长 128 个字符。" + }, + "labels": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "自定义标签。" + }, + "ds_type": { + "type": "string", + "description": "数据源类型标识(如 `prometheus`、`elasticsearch`)。" + }, + "ds_list": { + "type": "array", + "items": { + "type": "string" + }, + "description": "数据源名称匹配模式(支持通配符)。`ds_list` / `ds_ids` 至少一个非空,两者合并共同决定规则监控哪些数据源。" + }, + "ds_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "数据源 ID 列表,与 `ds_list` 合并后共同决定规则监控的数据源,使用 ID 可避免数据源改名后失效。`ds_list` 与 `ds_ids` 至少提供一个。" + }, + "enabled": { + "type": "boolean", + "description": "是否启用规则。必填,服务端解码时强制要求显式传入(包括 `false`)。更新为 `false` 时服务端会清理该规则的活跃告警。" + }, + "debug_log_enabled": { + "type": "boolean", + "description": "是否开启调试日志,开启后 edge 评估该规则时输出详细日志,用于排查规则未按预期触发等问题。" + }, + "rule_configs": { + "$ref": "#/components/schemas/AlertRuleConfigsV2", + "description": "检测配置,包含查询列表与触发/恢复条件,结构见 `AlertRuleConfigsV2`。" + }, + "cron_pattern": { + "type": "string", + "description": "调度表达式:6 段(含秒)cron 表达式或 `@every 30s` 间隔描述。不允许以 `CRON_TZ=` 或 `TZ=` 开头,时区请填写到 `timezone` 字段。" + }, + "timezone": { + "type": "string", + "default": "Asia/Shanghai", + "description": "告警规则执行时区,决定 cron 调度与生效时间窗口的解释方式。仅接受 IANA 时区名(如 `Asia/Shanghai`、`UTC`、`Europe/London`);不接受 `Local`、`UTC+8`、`CST` 等简写或偏移量。留空时按 `Asia/Shanghai` 处理。" + }, + "delay_seconds": { + "type": "integer", + "description": "评估时查询窗口向前偏移的秒数,用于补偿数据摄入延迟。" + }, + "enabled_times": { + "type": "array", + "description": "规则生效的时间窗口。省略或传空数组时,默认每天 00:00–23:59 生效。", + "default": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "items": { + "type": "object", + "properties": { + "days": { + "type": "array", + "items": { + "type": "integer" + }, + "description": "星期几(0=周日)。" + }, + "stime": { + "type": "string", + "description": "开始时间,如 `09:00`。" + }, + "etime": { + "type": "string", + "description": "结束时间,如 `18:00`。" + } + } + } + }, + "annotations": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "附加注解键值对,随告警事件下发;键不允许以 `$` 开头(该前缀保留给查询字段)。" + }, + "description_type": { + "type": "string", + "enum": [ + "text", + "markdown" + ], + "default": "text", + "description": "描述内容的格式。省略或为空时默认使用 `text`。`text` = 纯文本;`markdown` = Markdown 格式,告警详情中按 Markdown 渲染。" + }, + "description": { + "type": "string", + "description": "规则描述,Markdown 格式。" + }, + "channel_ids": { + "type": "array", + "items": { + "type": "integer", + "format": "uint64" + }, + "description": "告警发送到的协作空间 ID 列表。可为空,告警将通过全局集成路由。" + }, + "repeat_interval": { + "type": "integer", + "format": "int64", + "description": "通知重复间隔(秒)。小于 1 时按默认值 3600 处理。" + }, + "repeat_total": { + "type": "integer", + "format": "int64", + "description": "最大重复通知次数。小于 1 时按默认值 3 处理。" + }, + "investigation_targets": { + "type": "array", + "items": { + "$ref": "#/components/schemas/InvestigationTarget" + }, + "description": "告警事件详情页关联的排障入口列表,最多 20 项,不允许重复。更新接口中该字段按 presence 处理:省略时保留原配置,传 `[]` 清空。", + "x-flashduty-preserve-absence": true + }, + "creator_id": { + "type": "integer", + "format": "uint64", + "description": "创建人 ID,由服务端按当前用户自动填充,客户端传入将被忽略。" + }, + "creator_name": { + "type": "string", + "description": "创建人名称,由服务端自动填充,客户端传入将被忽略。" + }, + "updater_id": { + "type": "integer", + "format": "uint64", + "description": "最近更新人 ID,由服务端自动填充,客户端传入将被忽略。" + }, + "updater_name": { + "type": "string", + "description": "最近更新人名称,由服务端自动填充,客户端传入将被忽略。" + }, + "created_at": { + "type": "integer", + "format": "int64", + "description": "创建时间,Unix 秒级时间戳,由服务端生成,客户端传入将被忽略。" + }, + "updated_at": { + "type": "integer", + "format": "int64", + "description": "最近更新时间,Unix 秒级时间戳,由服务端生成,客户端传入将被忽略。" + } + }, + "required": [ + "folder_id", + "name", + "ds_type", + "enabled", + "cron_pattern", + "rule_configs" + ] + }, + "AlertRuleConfigsV2": { + "type": "object", + "description": "V2 规则评估配置。", + "properties": { + "queries": { + "type": "array", + "description": "查询列表,至少一条;每条需唯一的 `name`(`R`、`__all__` 为保留名)与非空且不重复的 `expr`。", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "查询标识符(如 `A`),须匹配 `[A-Za-z][A-Za-z0-9_]*`;`R`、`__all__` 为保留名称,不可使用。" + }, + "expr": { + "type": "string", + "description": "查询表达式。" + }, + "label_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "作为告警事件标签的结果字段列表,相同标签组合归为同一告警;不可与 `value_fields` 重复,适用于表型结果(SQL/ES 等数据源)。" + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "参与阈值评估的数值结果字段列表(以 `$A.` 形式被阈值表达式引用);对阈值检查且数据源非 `prometheus`/`loki`/`victorialogs` 时必填,字段名不允许含 `.`。" + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "数据源相关的查询附加参数,键采用 `<数据源>.<参数>` 约定(如 `es.type`、`tencent_cls.limit`);大多数数据源无需配置。" + } + } + } + }, + "relate_queries": { + "type": "array", + "description": "可选的辅助查询,其结果作为上下文附加到告警事件中。每项须有唯一的 `name`(不与任何 query 名称重复)且 `expr` 非空。", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "辅助查询标识符。" + }, + "expr": { + "type": "string", + "description": "查询表达式。" + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "辅助查询的数据源相关附加参数,约定同 `queries[].args`。" + } + } + } + }, + "check_threshold": { + "$ref": "#/components/schemas/AlertRuleThresholdV2", + "description": "阈值检查配置,结构见 `AlertRuleThresholdV2`。" + }, + "check_anydata": { + "$ref": "#/components/schemas/AlertRuleAnyDataV2", + "description": "有数据检查配置:查询返回任意数据行时触发告警,结构见 `AlertRuleAnyDataV2`。" + }, + "check_nodata": { + "$ref": "#/components/schemas/AlertRuleNoDataV2", + "description": "无数据检查配置,结构见 `AlertRuleNoDataV2`。" + } + }, + "required": [ + "queries" + ] + }, + "AlertRuleThresholdV2": { + "type": "object", + "description": "阈值检查配置(lifecycle v2)。", + "properties": { + "enabled": { + "type": "boolean", + "description": "是否启用阈值检查。" + }, + "alerting_check_times": { + "type": "integer", + "description": "满足告警条件的次数达到该值后触发告警;启用时最小为 1、最大 10000。与 `alerting_window_size` 配合时表示最近 M 次评估中至少命中 N 次。" + }, + "alerting_window_size": { + "type": "integer", + "description": "可选的滑动窗口大小 M:最近 M 次评估中至少满足条件 `alerting_check_times` 次才触发。省略时为连续模式(连续 N 次命中)。取值须满足 `alerting_check_times` <= M <= 10000。" + }, + "recovery_check_times": { + "type": "integer", + "description": "满足恢复条件的次数达到该值后判定恢复,启用时最小为 1。" + }, + "critical": { + "type": "string", + "description": "Critical 级别阈值表达式,用 `$<查询名>` 或 `$<查询名>.` 引用查询结果,如 `$A > 90`;启用时三个级别至少配置一个。" + }, + "warning": { + "type": "string", + "description": "Warning 级别阈值表达式,语法同 `critical`。" + }, + "info": { + "type": "string", + "description": "Info 级别阈值表达式,语法同 `critical`。" + }, + "recovery_mode": { + "type": "string", + "enum": [ + "condition_clear", + "expression_match", + "recovery_query_match", + "manual" + ], + "description": "恢复判定方式(lifecycle v2),启用时必填。`condition_clear` = 告警表达式不再成立即恢复,不允许配置 `recovery`;`expression_match` = `recovery.expr` 阈值表达式成立时恢复;`recovery_query_match` = `recovery.expr` 查询表达式为真时恢复;`manual` = 不自动判定恢复,告警需人工处理,不推送恢复事件,不允许配置 `recovery`。" + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "恢复判定配置。仅 `recovery_mode` 为 `expression_match` 或 `recovery_query_match` 时必填(`recovery.expr` 非空),其余模式不允许传入。" + } + } + }, + "AlertRuleAnyDataV2": { + "type": "object", + "description": "有数据检查配置(lifecycle v2)。查询返回任意数据行时触发告警。", + "properties": { + "enabled": { + "type": "boolean", + "description": "是否启用有数据检查:查询返回任意数据行即触发告警。" + }, + "alerting_check_times": { + "type": "integer", + "description": "满足告警条件的次数达到该值后触发告警;启用时最小为 1、最大 10000。与 `alerting_window_size` 配合时表示最近 M 次评估中至少命中 N 次。" + }, + "alerting_window_size": { + "type": "integer", + "description": "可选的滑动窗口大小 M:最近 M 次评估中至少满足条件 `alerting_check_times` 次才触发。省略时为连续模式。取值须满足 `alerting_check_times` <= M <= 10000。" + }, + "recovery_check_times": { + "type": "integer", + "description": "满足恢复条件的次数达到该值后判定恢复,启用时最小为 1。" + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "有数据告警的事件级别,大小写敏感;启用时必填。" + }, + "recovery_mode": { + "type": "string", + "enum": [ + "data_absent", + "recovery_query_match", + "manual" + ], + "description": "恢复判定方式(lifecycle v2),启用时必填。`data_absent` = 查询无数据时恢复,不允许配置 `recovery`;`recovery_query_match` = `recovery.expr` 查询表达式为真时恢复,仅允许单个查询(`name=A`);`manual` = 不自动判定恢复,告警需人工处理,不推送恢复事件,不允许配置 `recovery`。" + }, + "recovery": { + "$ref": "#/components/schemas/AlertRuleRecoveryQueryV2", + "description": "恢复判定配置。仅 `recovery_mode` 为 `recovery_query_match` 时必填(`recovery.expr` 非空),其余模式不允许传入。" + } + } + }, + "AlertRuleNoDataV2": { + "type": "object", + "description": "无数据检查配置(lifecycle v2)。", + "properties": { + "enabled": { + "type": "boolean", + "description": "是否启用按序列的无数据检查:历史上有数据的序列查不到数据时触发告警。" + }, + "severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "无数据告警的事件级别,大小写敏感;启用按序列检查时必填。" + }, + "alert_on_empty_result": { + "type": "boolean", + "description": "所有查询都返回空结果时是否触发告警(全局空结果检查)。" + }, + "alert_on_empty_result_severity": { + "type": "string", + "enum": [ + "Critical", + "Warning", + "Info" + ], + "description": "空结果告警的事件级别,大小写敏感;仅在 `alert_on_empty_result` 开启时生效且必填。" + }, + "alerting_check_times": { + "type": "integer", + "description": "满足告警条件的次数达到该值后触发告警;启用时最小为 1、最大 10000。与 `alerting_window_size` 配合时表示最近 M 次评估中至少命中 N 次。" + }, + "alerting_window_size": { + "type": "integer", + "description": "可选的滑动窗口大小 M:最近 M 次评估中至少满足条件 `alerting_check_times` 次才触发。省略时为连续模式。取值须满足 `alerting_check_times` <= M <= 10000。" + }, + "recovery_check_times": { + "type": "integer", + "description": "满足恢复条件的次数达到该值后判定恢复,启用时最小为 1。" + }, + "end_mode": { + "type": "string", + "enum": [ + "data_reappears", + "data_reappears_or_timeout", + "manual" + ], + "description": "无数据告警的结束方式(lifecycle v2),启用时必填。`data_reappears` = 数据重新出现时恢复;`data_reappears_or_timeout` = 数据重现或超过 `auto_close_after_seconds` 秒后自动关闭,要求启用按序列无数据检查且 `auto_close_after_seconds` 为正数;`manual` = 不自动结束,告警需人工处理,不推送恢复事件。`data_reappears` 和 `manual` 模式下 `auto_close_after_seconds` 必须为 0。" + }, + "auto_close_after_seconds": { + "type": "integer", + "format": "int64", + "description": "自动关闭等待时间(秒)。仅 `end_mode` 为 `data_reappears_or_timeout` 时允许且必须为正数,其余模式必须为 0。" + } + } + }, + "AlertRuleRecoveryQueryV2": { + "type": "object", + "description": "lifecycle v2 的恢复判定配置。", + "properties": { + "expr": { + "type": "string", + "description": "恢复条件表达式:`expression_match` 模式下为阈值表达式(如 `$A < 90`),`recovery_query_match` 模式下为查询表达式。启用对应模式时必填且非空。" + }, + "value_fields": { + "type": "array", + "items": { + "type": "string" + }, + "description": "恢复表达式以 `$A.` 形式引用的数值结果字段,语义同查询的 `value_fields`。为空时不返回。" + }, + "args": { + "type": "object", + "additionalProperties": { + "type": "string" + }, + "description": "恢复查询的数据源附加参数,键约定同查询的 `args`(`<数据源>.<参数>`)。为空时不返回。" + } + } + }, + "InvestigationTarget": { + "type": "object", + "description": "告警事件的关联排障入口,为封闭的 tagged union:新增类型需服务端显式支持。", + "properties": { + "kind": { + "type": "string", + "enum": [ + "dashboard" + ], + "description": "排障入口类型,目前仅支持 `dashboard`。" + }, + "dashboard": { + "$ref": "#/components/schemas/DashboardInvestigationTarget", + "description": "`dashboard` 类型的入口配置;`kind` 为 `dashboard` 时必填。" + } + }, + "required": [ + "kind" + ] + }, + "DashboardInvestigationTarget": { + "type": "object", + "description": "dashboard 类型的排障入口配置。", + "properties": { + "dashboard_id": { + "type": "string", + "description": "目标仪表盘 ID,须为规范的 UUIDv7。" + }, + "target_id": { + "type": "string", + "description": "仪表盘内目标面板 ID,须为规范的 UUIDv7;可选。" + }, + "variable_bindings": { + "type": "object", + "additionalProperties": { + "$ref": "#/components/schemas/InvestigationVariableBinding" + }, + "description": "仪表盘变量绑定,键为仪表盘变量名。" + } + }, + "required": [ + "dashboard_id" + ] + }, + "InvestigationVariableBinding": { + "type": "object", + "description": "仪表盘变量与告警事件数据的绑定。", + "properties": { + "source": { + "type": "string", + "enum": [ + "event_label" + ], + "description": "绑定值来源,目前仅支持 `event_label`(取告警事件的标签值)。" + }, + "key": { + "type": "string", + "description": "告警事件标签名,须符合 Prometheus 标签命名规则,且不能使用保留标签。" + } + }, + "required": [ + "source", + "key" + ] } }, "securitySchemes": { @@ -42237,77 +42681,6 @@ } } }, - "/monit/rule/counter/node": { - "post": { - "description": "返回一个对象,key 为顶层文件夹名称,value 为该文件夹及其子孙下的规则总数。", - "operationId": "monit-rule-read-counter-node", - "requestBody": { - "content": { - "application/json": { - "example": {}, - "schema": { - "$ref": "#/components/schemas/RuleEmptyRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "content": { - "application/json": { - "example": { - "data": { - "Production": 10, - "Staging": 3 - }, - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "properties": { - "data": { - "$ref": "#/components/schemas/RuleCounterNodeResponse" - } - }, - "type": "object" - } - ] - } - } - }, - "description": "成功" - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "summary": "按文件夹节点查询规则统计", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-node", - "metadata": { - "sidebarTitle": "按文件夹节点查询规则统计" - } - } - } - }, "/monit/rule/counter/total": { "post": { "description": "返回当前账户下规则总数的历史时序数据,每个 `clock` 时间戳对应一个采样。", @@ -42383,46 +42756,18 @@ } } }, - "/monit/rule/create": { + "/monit/rule/delete": { "post": { - "description": "创建新的告警规则,返回带有分配 ID 的已创建规则。", - "operationId": "monit-rule-write-create", + "description": "通过 ID 删除单条告警规则。", + "operationId": "monit-rule-write-delete", "requestBody": { "content": { "application/json": { "example": { - "channel_ids": [ - 20001 - ], - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "name": "CPU High", - "rule_configs": { - "check_threshold": { - "alerting_check_times": 1, - "critical": "A", - "enabled": true, - "push_recovery_event": true, - "recovery": { - "mode": "invert" - }, - "recovery_check_times": 1 - }, - "queries": [ - { - "expr": "avg(cpu_usage_idle) < 10", - "name": "A" - } - ] - } + "id": 50001 }, "schema": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleIDRequest" } } }, @@ -42433,13 +42778,7 @@ "content": { "application/json": { "example": { - "data": { - "created_at": 1712000000, - "ds_type": "prometheus", - "folder_id": 100, - "id": 50001, - "name": "CPU High" - }, + "data": {}, "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" }, "schema": { @@ -42450,7 +42789,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/RuleEmptyResponse" } }, "type": "object" @@ -42474,31 +42813,34 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "创建告警规则", + "summary": "删除告警规则", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `name`、`ds_type`、`cron_pattern` 和 `rule_configs.queries` 为必填项。\n- `ds_list`(支持通配符)或 `ds_ids` 必须有一个非空。\n- `cron_pattern` 使用标准 5 字段 cron 语法。\n- `channel_ids` 可为空,告警将通过全局集成路由。\n- `name` 在 `folder_id` 内必须唯一;重名会返回 `InvalidParameter`。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-create", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-delete", "metadata": { - "sidebarTitle": "创建告警规则" + "sidebarTitle": "删除告警规则" } } } }, - "/monit/rule/delete": { + "/monit/rule/delete/batch": { "post": { - "description": "通过 ID 删除单条告警规则。", - "operationId": "monit-rule-write-delete", + "description": "在单次请求中删除多条告警规则。", + "operationId": "monit-rule-write-delete-batch", "requestBody": { "content": { "application/json": { "example": { - "id": 50001 + "ids": [ + 50001, + 50002 + ] }, "schema": { - "$ref": "#/components/schemas/RuleIDRequest" + "$ref": "#/components/schemas/RuleIDsRequest" } } }, @@ -42544,30 +42886,29 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "删除告警规则", + "summary": "批量删除告警规则", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-delete", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **30 次/分钟**;**5 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-delete-batch", "metadata": { - "sidebarTitle": "删除告警规则" + "sidebarTitle": "批量删除告警规则" } } } }, - "/monit/rule/delete/batch": { + "/monit/rule/export": { "post": { - "description": "在单次请求中删除多条告警规则。", - "operationId": "monit-rule-write-delete-batch", + "description": "将选定告警规则的配置导出为可移植的 JSON 数组,与 `POST /monit/rule/import` 兼容。", + "operationId": "monit-rule-read-export", "requestBody": { "content": { "application/json": { "example": { "ids": [ - 50001, - 50002 + 50001 ] }, "schema": { @@ -42582,7 +42923,17 @@ "content": { "application/json": { "example": { - "data": {}, + "data": [ + { + "cron_pattern": "0 * * * * *", + "ds_list": [ + "prometheus*" + ], + "ds_type": "prometheus", + "enabled": true, + "name": "CPU High" + } + ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" }, "schema": { @@ -42593,7 +42944,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/RuleEmptyResponse" + "$ref": "#/components/schemas/AlertRuleExportListResponse" } }, "type": "object" @@ -42617,29 +42968,48 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "批量删除告警规则", + "summary": "导出告警规则", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **30 次/分钟**;**5 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-delete-batch", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/天**;**200 次/分钟**;**20 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-export", "metadata": { - "sidebarTitle": "批量删除告警规则" + "sidebarTitle": "导出告警规则" } } } }, - "/monit/rule/dstypes": { + "/monit/rule/import": { "post": { - "description": "返回当前账户在创建告警规则时可使用的数据源类型(`DSType` 记录)列表,包括全局类型和账户自定义类型。", - "operationId": "monit-rule-read-dstypes", + "description": "从 JSON 数组导入一条或多条告警规则,返回每条规则的导入结果(成功或失败)。", + "operationId": "monit-rule-write-import", "requestBody": { "content": { "application/json": { - "example": {}, + "example": [ + { + "cron_pattern": "0 * * * * *", + "ds_list": [ + "prometheus*" + ], + "ds_type": "prometheus", + "enabled": true, + "folder_id": 100, + "name": "CPU High", + "rule_configs": { + "queries": [ + { + "expr": "avg(cpu_usage_idle) < 10", + "name": "A" + } + ] + } + } + ], "schema": { - "$ref": "#/components/schemas/RuleEmptyRequest" + "$ref": "#/components/schemas/RuleImportRequest" } } }, @@ -42652,11 +43022,8 @@ "example": { "data": [ { - "account_id": 0, - "id": 1, - "ident": "prometheus", - "name": "Prometheus", - "weight": 100 + "message": "", + "name": "CPU High" } ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" @@ -42669,7 +43036,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/RuleDsTypesResponse" + "$ref": "#/components/schemas/RuleImportResponse" } }, "type": "object" @@ -42693,33 +43060,31 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "查询可用的数据源类型", + "summary": "导入告警规则", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-dstypes", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **20 次/分钟**;**2 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 请求体为规则导出对象的 JSON 数组(与 `POST /monit/rule/export` 输出兼容)。\n- 每个对象必须包含 `folder_id`、`ds_type` 以及 `ds_list` 或 `ds_ids` 之一。\n- 部分规则可能失败(如名称重复),请检查每条结果的状态。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-import", "metadata": { - "sidebarTitle": "查询可用的数据源类型" + "sidebarTitle": "导入告警规则" } } } }, - "/monit/rule/export": { + "/monit/rule/list/basic": { "post": { - "description": "将选定告警规则的配置导出为可移植的 JSON 数组,与 `POST /monit/rule/import` 兼容。", - "operationId": "monit-rule-read-export", + "description": "返回指定文件夹下所有告警规则的基础信息。如需完整规则详情,请调用 `POST /monit/rule/v2/info`。", + "operationId": "monit-rule-read-list", "requestBody": { "content": { "application/json": { "example": { - "ids": [ - 50001 - ] + "folder_id": 100 }, "schema": { - "$ref": "#/components/schemas/RuleIDsRequest" + "$ref": "#/components/schemas/RuleListRequest" } } }, @@ -42732,13 +43097,15 @@ "example": { "data": [ { - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], + "active_alert_count": 2, + "created_at": 1710000000, "ds_type": "prometheus", "enabled": true, - "name": "CPU High" + "folder_id": 100, + "id": 50001, + "name": "CPU High", + "runtime_state": "normal", + "triggered": true } ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" @@ -42751,7 +43118,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/AlertRuleExportListResponse" + "$ref": "#/components/schemas/RuleBasicListResponse" } }, "type": "object" @@ -42775,48 +43142,35 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "导出告警规则", + "summary": "查询告警规则列表", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/天**;**200 次/分钟**;**20 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-export", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |\n\n## 使用说明\n\n- 将 `folder_id` 设为 `0` 可列出当前用户有权查看的所有文件夹下的规则。\n- `triggered` 字段表示该规则当前是否有活跃告警。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-list", "metadata": { - "sidebarTitle": "导出告警规则" + "sidebarTitle": "查询告警规则列表" } } } }, - "/monit/rule/import": { + "/monit/rule/move": { "post": { - "description": "从 JSON 数组导入一条或多条告警规则,返回每条规则的导入结果(成功或失败)。", - "operationId": "monit-rule-write-import", + "description": "将一条或多条告警规则移动到其他文件夹。", + "operationId": "monit-rule-write-move", "requestBody": { "content": { "application/json": { - "example": [ - { - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "name": "CPU High", - "rule_configs": { - "queries": [ - { - "expr": "avg(cpu_usage_idle) < 10", - "name": "A" - } - ] - } - } - ], + "example": { + "dest_folder_id": 200, + "ids": [ + 50001, + 50002 + ] + }, "schema": { - "$ref": "#/components/schemas/RuleImportRequest" + "$ref": "#/components/schemas/RuleMoveRequest" } } }, @@ -42843,7 +43197,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/RuleImportResponse" + "$ref": "#/components/schemas/RuleNameMessageListResponse" } }, "type": "object" @@ -42867,31 +43221,38 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "导入告警规则", + "summary": "移动告警规则到文件夹", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **20 次/分钟**;**2 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 请求体为规则导出对象的 JSON 数组(与 `POST /monit/rule/export` 输出兼容)。\n- 每个对象必须包含 `folder_id`、`ds_type` 以及 `ds_list` 或 `ds_ids` 之一。\n- 部分规则可能失败(如名称重复),请检查每条结果的状态。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-import", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 如果目标文件夹中已存在同名规则,该规则会被跳过;请检查每条结果的 `message` 以识别冲突。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-move", "metadata": { - "sidebarTitle": "导入告警规则" + "sidebarTitle": "移动告警规则到文件夹" } } } }, - "/monit/rule/info": { + "/monit/rule/update/fields": { "post": { - "description": "通过 ID 返回告警规则的完整配置,包括规则查询、阈值和通知设置。", - "operationId": "monit-rule-read-info", + "description": "一次性更新多条告警规则的特定字段,仅应用 `fields` 列表中指定的字段。", + "operationId": "monit-rule-write-fields-update", "requestBody": { "content": { "application/json": { "example": { - "id": 50001 + "enabled": false, + "fields": [ + "enabled" + ], + "ids": [ + 50001, + 50002 + ] }, "schema": { - "$ref": "#/components/schemas/RuleIDRequest" + "$ref": "#/components/schemas/RuleFieldsUpdateRequest" } } }, @@ -42902,20 +43263,16 @@ "content": { "application/json": { "example": { - "data": { - "channel_ids": [ - 20001 - ], - "cron_pattern": "0 * * * * *", - "ds_list": [ - "prometheus*" - ], - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "id": 50001, - "name": "CPU High" - }, + "data": [ + { + "message": "", + "name": "CPU High" + }, + { + "message": "", + "name": "Disk High" + } + ], "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" }, "schema": { @@ -42926,7 +43283,7 @@ { "properties": { "data": { - "$ref": "#/components/schemas/AlertRuleInfoResponse" + "$ref": "#/components/schemas/RuleNameMessageListResponse" } }, "type": "object" @@ -42950,74 +43307,123 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "查看告警规则详情", + "summary": "批量更新规则字段", "tags": [ "Monitors/告警规则" ], "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-info", + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 在 `fields` 数组中指定要更新的字段名,如 `[\"enabled\", \"channel_ids\"]`。\n- 仅更新指定字段,其他字段保持不变。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-fields-update", "metadata": { - "sidebarTitle": "查看告警规则详情" + "sidebarTitle": "批量更新规则字段" } } } }, - "/monit/rule/list/basic": { + "/monit/rule/v2/info": { "post": { - "description": "返回指定文件夹下所有告警规则的基础信息。如需完整规则详情,请调用 `POST /monit/rule/info`。", - "operationId": "monit-rule-read-list", - "requestBody": { - "content": { - "application/json": { - "example": { - "folder_id": 100 - }, - "schema": { - "$ref": "#/components/schemas/RuleListRequest" - } - } - }, - "required": true + "operationId": "monit-rule-read-info-v2", + "summary": "获取告警规则详情 V2", + "description": "通过 ID 返回告警规则的完整 V2 配置,包含 lifecycle v2 的恢复与结束模式设置。", + "tags": [ + "Monitors/告警规则" + ], + "x-mint": { + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |\n\n## 使用说明\n\n- `id` 必填且不能为 `0`,否则返回 `InvalidParameter`。\n- 规则不存在时返回 `InvalidParameter`(`alert rule not found`)。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-info-v2", + "metadata": { + "sidebarTitle": "获取告警规则详情 V2" + } }, "responses": { "200": { + "description": "成功", "content": { "application/json": { - "example": { - "data": [ - { - "active_alert_count": 2, - "created_at": 1710000000, - "ds_type": "prometheus", - "enabled": true, - "folder_id": 100, - "id": 50001, - "name": "CPU High", - "runtime_state": "normal", - "triggered": true - } - ], - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, "schema": { "allOf": [ { "$ref": "#/components/schemas/SuccessEnvelope" }, { + "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleBasicListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } - }, - "type": "object" + } } ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } - }, - "description": "成功" + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -43032,71 +43438,125 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "查询告警规则列表", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则查看**(`monit`) |\n\n## 使用说明\n\n- 将 `folder_id` 设为 `0` 可列出当前用户有权查看的所有文件夹下的规则。\n- `triggered` 字段表示该规则当前是否有活跃告警。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-read-list", - "metadata": { - "sidebarTitle": "查询告警规则列表" - } - } - } - }, - "/monit/rule/move": { - "post": { - "description": "将一条或多条告警规则移动到其他文件夹。", - "operationId": "monit-rule-write-move", "requestBody": { + "required": true, "content": { "application/json": { - "example": { - "dest_folder_id": 200, - "ids": [ - 50001, - 50002 - ] - }, "schema": { - "$ref": "#/components/schemas/RuleMoveRequest" + "$ref": "#/components/schemas/RuleIDRequest" + }, + "example": { + "id": 50001 } } - }, - "required": true + } + } + } + }, + "/monit/rule/v2/create": { + "post": { + "operationId": "monit-rule-write-create-v2", + "summary": "创建告警规则 V2", + "description": "创建新的 V2 告警规则,返回带有分配 ID 的已创建规则。", + "tags": [ + "Monitors/告警规则" + ], + "x-mint": { + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **300 次/分钟**;**20 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `name`、`ds_type`、`enabled`、`cron_pattern` 和 `rule_configs.queries` 为必填项;`ds_list`(支持通配符)或 `ds_ids` 必须有一个非空。\n- `enabled` 必须显式传入(包括 `false`),缺失时返回 `InvalidParameter`。\n- `id`、`account_id`、`creator_*`、`updater_*`、`created_at`、`updated_at` 由服务端赋值,客户端传入将被忽略。\n- `name` 在 `folder_id` 内必须唯一;重名会返回 `InvalidParameter`。\n- `channel_ids` 可为空,告警将通过全局集成路由。\n- 请求体容忍额外的未知字段(向前兼容),未知字段会被忽略。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-create-v2", + "metadata": { + "sidebarTitle": "创建告警规则 V2" + } }, "responses": { "200": { + "description": "成功", "content": { "application/json": { - "example": { - "data": [ - { - "message": "", - "name": "CPU High" - } - ], - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, "schema": { "allOf": [ { "$ref": "#/components/schemas/SuccessEnvelope" }, { + "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/RuleNameMessageListResponse" + "$ref": "#/components/schemas/AlertRuleV2" } - }, - "type": "object" + } } ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712000000 + } } } - }, - "description": "成功" + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -43111,81 +43571,152 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "移动告警规则到文件夹", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 如果目标文件夹中已存在同名规则,该规则会被跳过;请检查每条结果的 `message` 以识别冲突。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-move", - "metadata": { - "sidebarTitle": "移动告警规则到文件夹" - } - } - } - }, - "/monit/rule/update": { - "post": { - "description": "替换已有告警规则的完整配置,所有字段将被覆盖。", - "operationId": "monit-rule-write-update", "requestBody": { + "required": true, "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/AlertRuleV2" + }, "example": { - "cron_pattern": "0 * * * * *", + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", "ds_list": [ "prometheus*" ], - "ds_type": "prometheus", "enabled": true, - "folder_id": 100, - "id": 50001, - "name": "CPU High v2", + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 + ], "rule_configs": { "queries": [ { - "expr": "avg(cpu_usage_idle) < 5", - "name": "A" + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" } - ] + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 90", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } } - }, - "schema": { - "$ref": "#/components/schemas/AlertRule" } } - }, - "required": true + } + } + } + }, + "/monit/rule/v2/update": { + "post": { + "operationId": "monit-rule-write-update-v2", + "summary": "更新告警规则 V2", + "description": "按 ID 全量替换告警规则的 V2 配置,返回更新后的规则。", + "tags": [ + "Monitors/告警规则" + ], + "x-mint": { + "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **300 次/分钟**;**20 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `id` 必填且对应规则必须已存在,否则返回 `InvalidParameter`。\n- 本接口为全量字段替换语义:除下列例外外,未传入的字段按零值保存,建议先调用 `/monit/rule/v2/info` 获取完整配置后再修改。\n- `enabled` 必须显式传入(包括 `false`),缺失时返回 `InvalidParameter`;更新为 `false` 时服务端会清理该规则的活跃告警。\n- `investigation_targets` 为例外:省略时保留原配置,传 `[]` 清空,传值则整体替换。\n- `folder_id` 不可通过本接口修改,调整文件夹请使用 `/monit/rule/move`。\n- `account_id`、`creator_*`、`updater_*`、`created_at`、`updated_at` 由服务端维护,传入将被忽略。\n- `name` 在 `folder_id` 内必须唯一;重名会返回 `InvalidParameter`。\n- 请求体容忍额外的未知字段(向前兼容),未知字段会被忽略。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", + "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-update-v2", + "metadata": { + "sidebarTitle": "更新告警规则 V2" + } }, "responses": { "200": { + "description": "成功", "content": { "application/json": { - "example": { - "data": { - "id": 50001, - "updated_at": 1712100000 - }, - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" - }, "schema": { "allOf": [ { "$ref": "#/components/schemas/SuccessEnvelope" }, { + "type": "object", "properties": { "data": { - "$ref": "#/components/schemas/AlertRule" + "$ref": "#/components/schemas/AlertRuleV2" } - }, - "type": "object" + } } ] + }, + "example": { + "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4", + "data": { + "id": 50001, + "account_id": 888, + "folder_id": 100, + "name": "CPU High", + "labels": {}, + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" + ], + "ds_ids": [], + "enabled": true, + "debug_log_enabled": false, + "rule_configs": { + "queries": [ + { + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" + } + ], + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } + }, + "cron_pattern": "0 * * * * *", + "timezone": "Asia/Shanghai", + "delay_seconds": 0, + "enabled_times": [ + { + "days": [ + 1, + 2, + 3, + 4, + 5, + 6, + 0 + ], + "stime": "00:00", + "etime": "23:59" + } + ], + "annotations": {}, + "description_type": "text", + "description": "", + "channel_ids": [ + 20001 + ], + "repeat_interval": 3600, + "repeat_total": 3, + "investigation_targets": [], + "creator_id": 66, + "creator_name": "zhangsan", + "updater_id": 66, + "updater_name": "zhangsan", + "created_at": 1712000000, + "updated_at": 1712003600 + } } } - }, - "description": "成功" + } }, "400": { "$ref": "#/components/responses/BadRequest" @@ -43200,101 +43731,45 @@ "$ref": "#/components/responses/ServerError" } }, - "summary": "更新告警规则", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- `id` 为必填项。其他字段与 `POST /monit/rule/create` 的规则相同。\n- 名称在所在文件夹内必须保持唯一;重名会返回 `InvalidParameter`。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-update", - "metadata": { - "sidebarTitle": "更新告警规则" - } - } - } - }, - "/monit/rule/update/fields": { - "post": { - "description": "一次性更新多条告警规则的特定字段,仅应用 `fields` 列表中指定的字段。", - "operationId": "monit-rule-write-fields-update", "requestBody": { + "required": true, "content": { "application/json": { + "schema": { + "$ref": "#/components/schemas/AlertRuleV2" + }, "example": { - "enabled": false, - "fields": [ - "enabled" + "folder_id": 100, + "name": "CPU High", + "ds_type": "prometheus", + "ds_list": [ + "prometheus*" ], - "ids": [ - 50001, - 50002 - ] - }, - "schema": { - "$ref": "#/components/schemas/RuleFieldsUpdateRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "content": { - "application/json": { - "example": { - "data": [ - { - "message": "", - "name": "CPU High" - }, + "enabled": true, + "cron_pattern": "0 * * * * *", + "channel_ids": [ + 20001 + ], + "rule_configs": { + "queries": [ { - "message": "", - "name": "Disk High" + "name": "A", + "expr": "100 - avg(cpu_usage_idle)" } ], - "request_id": "01HK8XQE3Z7JM2NTFQ5YJ8P9R4" + "check_threshold": { + "enabled": true, + "alerting_check_times": 3, + "alerting_window_size": 5, + "recovery_check_times": 2, + "critical": "$A > 95", + "warning": "$A > 80", + "recovery_mode": "condition_clear" + } }, - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/SuccessEnvelope" - }, - { - "properties": { - "data": { - "$ref": "#/components/schemas/RuleNameMessageListResponse" - } - }, - "type": "object" - } - ] - } + "id": 50001 } - }, - "description": "成功" - }, - "400": { - "$ref": "#/components/responses/BadRequest" - }, - "401": { - "$ref": "#/components/responses/Unauthorized" - }, - "429": { - "$ref": "#/components/responses/TooManyRequests" - }, - "500": { - "$ref": "#/components/responses/ServerError" - } - }, - "summary": "批量更新规则字段", - "tags": [ - "Monitors/告警规则" - ], - "x-mint": { - "content": "## 限制说明\n\n| 项目 | 说明 |\n| ---- | ---- |\n| 速率限制 | 每个账户 **1,000 次/分钟**;**50 次/秒** |\n| 权限要求 | **告警规则管理**(`monit`) |\n\n## 使用说明\n\n- 在 `fields` 数组中指定要更新的字段名,如 `[\"enabled\", \"channel_ids\"]`。\n- 仅更新指定字段,其他字段保持不变。\n- 每次调用都会记录到账户审计日志,请不要把敏感信息放在请求字段中。", - "href": "/zh/api-reference/monitors/alert-rules/monit-rule-write-fields-update", - "metadata": { - "sidebarTitle": "批量更新规则字段" + } } } } diff --git a/docs.json b/docs.json index 289a2b1e..b55abf52 100644 --- a/docs.json +++ b/docs.json @@ -2470,9 +2470,9 @@ "icon": "diamond-exclamation", "pages": [ "POST /monit/rule/list/basic", - "POST /monit/rule/info", - "POST /monit/rule/create", - "POST /monit/rule/update", + "POST /monit/rule/v2/info", + "POST /monit/rule/v2/create", + "POST /monit/rule/v2/update", "POST /monit/rule/delete", "POST /monit/rule/delete/batch", "POST /monit/rule/update/fields", @@ -2481,9 +2481,7 @@ "POST /monit/rule/move", "POST /monit/rule/audits", "POST /monit/rule/audit/detail", - "POST /monit/rule/dstypes", "POST /monit/rule/counter/total", - "POST /monit/rule/counter/node", "POST /monit/rule/counter/channel" ] }, @@ -3846,9 +3844,9 @@ "icon": "diamond-exclamation", "pages": [ "POST /monit/rule/list/basic", - "POST /monit/rule/info", - "POST /monit/rule/create", - "POST /monit/rule/update", + "POST /monit/rule/v2/info", + "POST /monit/rule/v2/create", + "POST /monit/rule/v2/update", "POST /monit/rule/delete", "POST /monit/rule/delete/batch", "POST /monit/rule/update/fields", @@ -3857,9 +3855,7 @@ "POST /monit/rule/move", "POST /monit/rule/audits", "POST /monit/rule/audit/detail", - "POST /monit/rule/dstypes", "POST /monit/rule/counter/total", - "POST /monit/rule/counter/node", "POST /monit/rule/counter/channel" ] }, diff --git a/en/openapi/api-catalog.mdx b/en/openapi/api-catalog.mdx index 53a0653c..1f1d34d7 100644 --- a/en/openapi/api-catalog.mdx +++ b/en/openapi/api-catalog.mdx @@ -278,9 +278,9 @@ All endpoint URLs use `https://api.flashcat.cloud` as the base, authenticated vi | Method | Endpoint | Description | | :--- | :--- | :--- | | POST | [`/monit/rule/list/basic`](/en/api-reference/monitors/alert-rules/monit-rule-read-list) | List alert rules | -| POST | [`/monit/rule/info`](/en/api-reference/monitors/alert-rules/monit-rule-read-info) | Get alert rule detail | -| POST | [`/monit/rule/create`](/en/api-reference/monitors/alert-rules/monit-rule-write-create) | Create alert rule | -| POST | [`/monit/rule/update`](/en/api-reference/monitors/alert-rules/monit-rule-write-update) | Update alert rule | +| POST | [`/monit/rule/v2/info`](/en/api-reference/monitors/alert-rules/monit-rule-read-info-v2) | Get alert rule detail (V2) | +| POST | [`/monit/rule/v2/create`](/en/api-reference/monitors/alert-rules/monit-rule-write-create-v2) | Create alert rule (V2) | +| POST | [`/monit/rule/v2/update`](/en/api-reference/monitors/alert-rules/monit-rule-write-update-v2) | Update alert rule (V2) | | POST | [`/monit/rule/delete`](/en/api-reference/monitors/alert-rules/monit-rule-write-delete) | Delete alert rule | | POST | [`/monit/rule/delete/batch`](/en/api-reference/monitors/alert-rules/monit-rule-write-delete-batch) | Batch delete alert rules | | POST | [`/monit/rule/update/fields`](/en/api-reference/monitors/alert-rules/monit-rule-write-fields-update) | Batch update rule fields | @@ -289,9 +289,7 @@ All endpoint URLs use `https://api.flashcat.cloud` as the base, authenticated vi | POST | [`/monit/rule/move`](/en/api-reference/monitors/alert-rules/monit-rule-write-move) | Move alert rules to folder | | POST | [`/monit/rule/audits`](/en/api-reference/monitors/alert-rules/monit-rule-read-audits) | List rule change history | | POST | [`/monit/rule/audit/detail`](/en/api-reference/monitors/alert-rules/monit-rule-read-audit-detail) | Get rule audit snapshot | -| POST | [`/monit/rule/dstypes`](/en/api-reference/monitors/alert-rules/monit-rule-read-dstypes) | List available datasource types | | POST | [`/monit/rule/counter/total`](/en/api-reference/monitors/alert-rules/monit-rule-read-counter-total) | Get rule counter time series | -| POST | [`/monit/rule/counter/node`](/en/api-reference/monitors/alert-rules/monit-rule-read-counter-node) | Get rule counts by folder node | | POST | [`/monit/rule/counter/channel`](/en/api-reference/monitors/alert-rules/monit-rule-read-counter-channel) | Get rule counts by channel | ### Data sources diff --git a/zh/openapi/api-catalog.mdx b/zh/openapi/api-catalog.mdx index d18894b6..db726c12 100644 --- a/zh/openapi/api-catalog.mdx +++ b/zh/openapi/api-catalog.mdx @@ -278,9 +278,9 @@ Flashduty Open API 提供 **339** 个接口,覆盖 On-call、Monitors、RUM、 | 方法 | 接口 | 描述 | | :--- | :--- | :--- | | POST | [`/monit/rule/list/basic`](/zh/api-reference/monitors/alert-rules/monit-rule-read-list) | 查询告警规则列表 | -| POST | [`/monit/rule/info`](/zh/api-reference/monitors/alert-rules/monit-rule-read-info) | 查看告警规则详情 | -| POST | [`/monit/rule/create`](/zh/api-reference/monitors/alert-rules/monit-rule-write-create) | 创建告警规则 | -| POST | [`/monit/rule/update`](/zh/api-reference/monitors/alert-rules/monit-rule-write-update) | 更新告警规则 | +| POST | [`/monit/rule/v2/info`](/zh/api-reference/monitors/alert-rules/monit-rule-read-info-v2) | 获取告警规则详情 V2 | +| POST | [`/monit/rule/v2/create`](/zh/api-reference/monitors/alert-rules/monit-rule-write-create-v2) | 创建告警规则 V2 | +| POST | [`/monit/rule/v2/update`](/zh/api-reference/monitors/alert-rules/monit-rule-write-update-v2) | 更新告警规则 V2 | | POST | [`/monit/rule/delete`](/zh/api-reference/monitors/alert-rules/monit-rule-write-delete) | 删除告警规则 | | POST | [`/monit/rule/delete/batch`](/zh/api-reference/monitors/alert-rules/monit-rule-write-delete-batch) | 批量删除告警规则 | | POST | [`/monit/rule/update/fields`](/zh/api-reference/monitors/alert-rules/monit-rule-write-fields-update) | 批量更新规则字段 | @@ -289,9 +289,7 @@ Flashduty Open API 提供 **339** 个接口,覆盖 On-call、Monitors、RUM、 | POST | [`/monit/rule/move`](/zh/api-reference/monitors/alert-rules/monit-rule-write-move) | 移动告警规则到文件夹 | | POST | [`/monit/rule/audits`](/zh/api-reference/monitors/alert-rules/monit-rule-read-audits) | 查询规则变更历史 | | POST | [`/monit/rule/audit/detail`](/zh/api-reference/monitors/alert-rules/monit-rule-read-audit-detail) | 查看规则审计快照 | -| POST | [`/monit/rule/dstypes`](/zh/api-reference/monitors/alert-rules/monit-rule-read-dstypes) | 查询可用的数据源类型 | | POST | [`/monit/rule/counter/total`](/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-total) | 查看规则数量时序 | -| POST | [`/monit/rule/counter/node`](/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-node) | 按文件夹节点查询规则统计 | | POST | [`/monit/rule/counter/channel`](/zh/api-reference/monitors/alert-rules/monit-rule-read-counter-channel) | 按协作空间查询规则统计 | ### 告警数据源