feat: configure static and dynamic alert rules

This commit is contained in:
zxr
2026-07-20 21:59:57 +08:00
parent 947fa2f9b9
commit 9cbacf5998
5 changed files with 209 additions and 57 deletions

View File

@@ -68,10 +68,11 @@ export const createRule = (data: {
severity_id: number
enabled?: boolean
metric_name?: string
query_expr?: string
data_source?: string
threshold?: number
compare_op?: string
duration?: number
eval_interval?: number
baseline_config?: string
labels?: string
annotations?: string
@@ -86,10 +87,11 @@ export const updateRule = (data: {
severity_id?: number
enabled?: boolean
metric_name?: string
query_expr?: string
data_source?: string
threshold?: number
compare_op?: string
duration?: number
eval_interval?: number
baseline_config?: string
labels?: string
annotations?: string

View File

@@ -20,12 +20,13 @@ export interface AlertRule {
name: string
data_source: string
metric_name: string
rule_type: 'static' | 'dynamic' | 'promql'
rule_type: 'static' | 'dynamic'
compare_op: '>' | '>=' | '<' | '<=' | '==' | '!='
threshold: string | number
duration: number
eval_interval: number
severity_code: string
baseline_config?: string
labels?: Record<string, string>
annotations?: Record<string, string>
}
@@ -105,12 +106,11 @@ export const TEMPLATE_CATEGORIES = [
// 数据源选项
export const DATA_SOURCES = [
{ value: 'dc-host', label: '主机/操作系统指标' },
{ value: 'dc-hardware', label: '服务器硬件指标' },
{ value: 'dc-network', label: '网络设备指标' },
{ value: 'dc-database', label: '数据库指标' },
{ value: 'dc-middleware', label: '中间件指标' },
{ value: 'dc-virtualization', label: '虚拟化指标' },
{ value: 'dc-env', label: '动力/环境/安防指标' },
{ value: 'dc-security', label: '安全设备指标' },
{ value: 'dc-storage', label: '存储设备指标' },
{ value: 'dc-room-device', label: '机房设备指标' },
]
// 比较运算符选项
@@ -127,7 +127,6 @@ export const COMPARE_OPERATORS = [
export const RULE_TYPES = [
{ value: 'static', label: '静态阈值' },
{ value: 'dynamic', label: '动态阈值' },
{ value: 'promql', label: 'PromQL 表达式' },
]
// ==================== 告警模板接口 ====================