Skip to content

Commit b40dbd3

Browse files
committed
Revert "Merge branch 'feature/alert-healing-with-observation-window' into develop"
This reverts commit bc51939, reversing changes made to 7ae82d1.
1 parent bc51939 commit b40dbd3

File tree

12 files changed

+70
-1492
lines changed

12 files changed

+70
-1492
lines changed

docs/alerting/database-design.md

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,14 @@
22

33
## 概述
44

5-
本文档为最新数据库设计,总计包含 7 张表:
5+
本文档为最新数据库设计,总计包含 6 张表:
66

77
- alert_issues
88
- alert_issue_comments
99
- alert_meta_change_logs
1010
- alert_rules
1111
- alert_rule_metas
1212
- service_states
13-
- heal_actions
1413

1514
## 数据表设计
1615

@@ -112,7 +111,7 @@
112111

113112
---
114113

115-
### 6) service_states(服务状态表)
114+
### 7) service_states(服务状态表)
116115

117116
追踪服务在某一版本上的健康状态与处置进度。
118117

@@ -128,34 +127,6 @@
128127
**索引建议:**
129128
- PRIMARY KEY: `(service, version)`
130129

131-
---
132-
133-
### 7) heal_actions(告警治愈解决方案表)
134-
135-
存储不同故障域对应的治愈方案和规则。
136-
137-
| 字段名 | 类型 | 说明 |
138-
|--------|------|------|
139-
| id | varchar(255) PK | 治愈方案 ID |
140-
| desc | text | 简单描述,如 action 是处理什么告警场景的 |
141-
| type | varchar(255) | 对应的故障域类型 |
142-
| rules | jsonb | 条件规则:{condition1: action1, condition2: action2} |
143-
144-
**索引建议:**
145-
- PRIMARY KEY: `id`
146-
- INDEX: `(type)`
147-
148-
**示例数据:**
149-
```sql
150-
INSERT INTO heal_actions (id, desc, type, rules) VALUES
151-
('service_version_rollback', '服务版本回滚方案', 'service_version_issue',
152-
'{"deployment_status": "deploying", "action": "rollback", "target": "previous_version"}'),
153-
('service_version_alert', '服务版本告警方案', 'service_version_issue',
154-
'{"deployment_status": "deployed", "action": "alert", "message": "版本已发布,暂不支持自动回滚"}');
155-
```
156-
157-
TODO: health_state映射逻辑
158-
159130
## 数据关系(ER)
160131

161132
```mermaid
@@ -204,25 +175,13 @@ erDiagram
204175
text content
205176
}
206177
207-
heal_actions {
208-
varchar id PK
209-
text desc
210-
varchar type
211-
jsonb rules
212-
}
213-
214178
%% 通过 service 等标签在应用层逻辑关联
215179
alert_rule_metas ||..|| alert_rules : "by alert_name"
216180
service_states ||..|| alert_rule_metas : "by service/version labels"
217-
heal_actions ||..|| alert_issues : "by fault domain analysis"
218181
```
219182

220183
## 数据流转
221184

222185
1.`alert_rules` 为模版,结合 `alert_rule_metas` 渲染出面向具体服务/版本等的规则(labels 可为空 `{}` 表示全局默认,或包含如 service/version 等标签)。
223186
2. 指标或规则参数发生调整时,记录到 `alert_meta_change_logs`
224-
3. 规则触发创建 `alert_issues`;处理过程中的动作写入 `alert_issue_comments`
225-
4. **告警治愈流程**
226-
- P0 告警:根据 `alert_issues.labels` 识别故障域,查询 `heal_actions` 获取治愈方案
227-
- 执行治愈操作(如回滚),成功后更新 `alert_issues``service_states` 状态
228-
- P1/P2 告警:直接进入下钻分析,记录分析结果到 `alert_issue_comments`
187+
3. 规则触发创建 `alert_issues`;处理过程中的动作写入 `alert_issue_comments`

go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ require (
99
github.com/lib/pq v1.10.9
1010
github.com/redis/go-redis/v9 v9.5.1
1111
github.com/rs/zerolog v1.34.0
12-
github.com/stretchr/testify v1.11.1
1312
)
1413

1514
require (
1615
github.com/bytedance/sonic v1.13.3 // indirect
1716
github.com/bytedance/sonic/loader v0.2.4 // indirect
1817
github.com/cespare/xxhash/v2 v2.2.0 // indirect
1918
github.com/cloudwego/base64x v0.1.5 // indirect
20-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2119
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
2220
github.com/gabriel-vasile/mimetype v1.4.9 // indirect
2321
github.com/gin-contrib/cors v1.7.6 // indirect
@@ -41,7 +39,6 @@ require (
4139
github.com/modern-go/reflect2 v1.0.2 // indirect
4240
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
4341
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
44-
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4542
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
4643
github.com/ugorji/go/codec v1.3.0 // indirect
4744
golang.org/x/arch v0.18.0 // indirect

internal/alerting/database/database.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,3 @@ func (d *Database) ExecContext(ctx context.Context, q string, args ...any) (sql.
3838
func (d *Database) QueryContext(ctx context.Context, q string, args ...any) (*sql.Rows, error) {
3939
return d.db.QueryContext(ctx, q, args...)
4040
}
41-
42-
// QueryRowContext exposes database/sql QueryRowContext for single row SELECT queries.
43-
func (d *Database) QueryRowContext(ctx context.Context, q string, args ...any) *sql.Row {
44-
return d.db.QueryRowContext(ctx, q, args...)
45-
}

0 commit comments

Comments
 (0)