From f28d4b78e746e61c1efaee71c9cff87fec5d5b41 Mon Sep 17 00:00:00 2001 From: IanShaw027 <131567472+IanShaw027@users.noreply.github.com> Date: Mon, 12 Jan 2026 11:43:15 +0800 Subject: [PATCH] =?UTF-8?q?feat(ops):=20=E5=89=8D=E7=AB=AF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=8C=87=E6=A0=87=E9=98=88=E5=80=BC=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=92=8CAPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加OpsMetricThresholds类型定义 - 新增getMetricThresholds和updateMetricThresholds API方法 --- frontend/src/api/admin/ops.ts | 24 +++++++++++++++++++++++- frontend/src/views/admin/ops/types.ts | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/frontend/src/api/admin/ops.ts b/frontend/src/api/admin/ops.ts index 1d1453f5..f52227ca 100644 --- a/frontend/src/api/admin/ops.ts +++ b/frontend/src/api/admin/ops.ts @@ -661,6 +661,14 @@ export interface EmailNotificationConfig { } } +export interface OpsMetricThresholds { + sla_percent_min?: number | null // SLA低于此值变红 + latency_p99_ms_max?: number | null // 延迟P99高于此值变红 + ttft_p99_ms_max?: number | null // TTFT P99高于此值变红 + request_error_rate_percent_max?: number | null // 请求错误率高于此值变红 + upstream_error_rate_percent_max?: number | null // 上游错误率高于此值变红 +} + export interface OpsDistributedLockSettings { enabled: boolean key: string @@ -681,6 +689,7 @@ export interface OpsAlertRuntimeSettings { reason: string }> } + thresholds: OpsMetricThresholds // 指标阈值配置 } export interface OpsAdvancedSettings { @@ -929,6 +938,17 @@ export async function updateAdvancedSettings(config: OpsAdvancedSettings): Promi return data } +// ==================== Metric Thresholds ==================== + +async function getMetricThresholds(): Promise { + const { data } = await apiClient.get('/admin/ops/settings/metric-thresholds') + return data +} + +async function updateMetricThresholds(thresholds: OpsMetricThresholds): Promise { + await apiClient.put('/admin/ops/settings/metric-thresholds', thresholds) +} + export const opsAPI = { getDashboardOverview, getThroughputTrend, @@ -952,7 +972,9 @@ export const opsAPI = { getAlertRuntimeSettings, updateAlertRuntimeSettings, getAdvancedSettings, - updateAdvancedSettings + updateAdvancedSettings, + getMetricThresholds, + updateMetricThresholds } export default opsAPI diff --git a/frontend/src/views/admin/ops/types.ts b/frontend/src/views/admin/ops/types.ts index 45ba031f..005d0427 100644 --- a/frontend/src/views/admin/ops/types.ts +++ b/frontend/src/views/admin/ops/types.ts @@ -14,6 +14,7 @@ export type { EmailNotificationConfig, OpsDistributedLockSettings, OpsAlertRuntimeSettings, + OpsMetricThresholds, OpsAdvancedSettings, OpsDataRetentionSettings, OpsAggregationSettings