feat(platform): include release in alert runbook

This commit is contained in:
lingniu
2026-07-04 15:59:20 +08:00
parent 7d6d1afbf2
commit a01a958e60
2 changed files with 6 additions and 3 deletions

View File

@@ -449,8 +449,9 @@ function normalizePriorityIssues(rows?: QualityPriorityIssue[]): PriorityIssueRo
return rows;
}
function notificationPolicyRunbookText(policies: QualityNotificationPolicy[], rules: AlertRuleRow[]) {
function notificationPolicyRunbookText(policies: QualityNotificationPolicy[], rules: AlertRuleRow[], platformRelease?: string) {
const activeRules = rules.filter((row) => row.count > 0);
const release = platformRelease?.trim();
const lines = policies.map((policy, index) => [
`${index + 1}. ${policy.name} / ${policy.target}`,
` 触发:${policy.condition}`,
@@ -462,6 +463,7 @@ function notificationPolicyRunbookText(policies: QualityNotificationPolicy[], ru
'【告警通知策略Runbook】',
`活跃规则:${activeRules.length.toLocaleString()}`,
`P0规则${activeRules.filter((row) => row.level === 'P0').length.toLocaleString()}`,
...(release ? [`运行版本:${release}`] : []),
'',
...lines,
'',
@@ -650,7 +652,7 @@ export function Quality({
copyText(priorityIssueDigestText(priorityRows, notificationPlan?.summary ?? summary, health?.runtime?.platformRelease, policies), '优先队列通知汇总');
};
const copyPolicyRunbook = () => {
copyText(notificationPolicyRunbookText(policies, rules), '通知策略Runbook');
copyText(notificationPolicyRunbookText(policies, rules, health?.runtime?.platformRelease), '通知策略Runbook');
};
return (

View File

@@ -2900,7 +2900,7 @@ test('shows alert rule and notification policy workspace on quality page', async
redisOnlineKeys: 368,
tdengineWritable: false,
mysqlWritable: true,
runtime: { requestTimeoutMs: 5000 }
runtime: { platformRelease: 'platform-20260704155607', requestTimeoutMs: 5000 }
},
traceId: 'trace-test',
timestamp: 1783094400000
@@ -2969,6 +2969,7 @@ test('shows alert rule and notification policy workspace on quality page', async
fireEvent.click(screen.getByRole('button', { name: '复制通知策略Runbook' }));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('【告警通知策略Runbook】'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('运行版本platform-20260704155607'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('P0 实时中断 / 接入运维 + 业务责任人'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('升级30 分钟升级'));
expect(writeText).toHaveBeenCalledWith(expect.stringContaining('验收:来源恢复并持续 10 分钟,车辆服务可查到实时与历史证据'));