feat(i18n): U45 AI告警分析模块i18n补全 — analyzerHelpers 25处硬编码中文→i18n.t()插值 + 预测图标双语兼容
This commit is contained in:
1 parent
05ee051879
commit
6288fa0071
5 files changed
+89
-31
No files matched your search
@@ -198,10 +198,10 @@ export function AIPredictiveAnalytics() {
|
||||
<div key={idx} className="p-4 rounded-lg border border-[var(--dg-border)] bg-[var(--dg-bg-tertiary)]/50">
|
||||
<div className="flex items-center justify-between mb-3">
|
||||
<div className="flex items-center gap-2">
|
||||
{prediction.name.includes('CPU') && <Cpu className="h-4 w-4 dg-text-blue" />}
|
||||
{prediction.name.includes('内存') && <MemoryStick className="h-4 w-4 dg-text-green" />}
|
||||
{prediction.name.includes('磁盘') && <HardDrive className="h-4 w-4 dg-text-yellow" />}
|
||||
{prediction.name.includes('网络') && <Network className="h-4 w-4 dg-text-purple" />}
|
||||
{(prediction.name.match(/CPU|cpu/i)) && <Cpu className="h-4 w-4 dg-text-blue" />}
|
||||
{(prediction.name.match(/memory|mem|内存/i)) && <MemoryStick className="h-4 w-4 dg-text-green" />}
|
||||
{(prediction.name.match(/disk|磁盘/i)) && <HardDrive className="h-4 w-4 dg-text-yellow" />}
|
||||
{(prediction.name.match(/network|网络/i)) && <Network className="h-4 w-4 dg-text-purple" />}
|
||||
<span className="font-medium text-[var(--dg-text-primary)]">{prediction.name}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
|
||||
@@ -43,14 +43,14 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
// CPU 告警
|
||||
if (metric.includes('cpu')) {
|
||||
return {
|
||||
rootCause: `检测到 ${target} 上 CPU 使用率达到 ${alert.currentValue},持续超过阈值 ${alert.threshold}。可能原因:1) 某进程存在死循环或高计算负载;2) GC 频繁触发(Java/Go 应用);3) 业务流量突增导致处理能力不足。`,
|
||||
rootCause: i18n.t('aiops.analyzer.cpuRootCause', { target, value: alert.currentValue, threshold: alert.threshold }),
|
||||
impact: isCritical
|
||||
? `CPU 持续高负载将导致服务响应延迟显著增加,严重时可能触发雪崩效应,影响全部依赖该节点的业务。`
|
||||
: `CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。`,
|
||||
? i18n.t('aiops.analyzer.cpuImpactCritical')
|
||||
: i18n.t('aiops.analyzer.cpuImpactWarning'),
|
||||
recommendations: [
|
||||
`登录 ${target} 执行 top/htop 定位高 CPU 进程`,
|
||||
i18n.t('aiops.analyzer.cpuRecLogin', { target }),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
`考虑临时扩容或将部分流量调度到其他节点`,
|
||||
i18n.t('aiops.analyzer.cpuRecScale'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
],
|
||||
autoFixScript: `#!/bin/bash\n# CPU 高负载诊断脚本 - ${target}\necho "${i18n.t('aiops.analysis.topCpuProcess')}"\nps aux --sort=-%cpu | head -11\necho ""\necho "${i18n.t('aiops.analyzerHelpers.systemLoad')}"\nuptime\necho ""\necho "${i18n.t('aiops.analyzerHelpers.highCpuProcessDetail')}"\nPID=$(ps aux --sort=-%cpu | sed -n '2p' | awk '{print $2}')\nif [ -n "$PID" ]; then\n echo "${i18n.t('aiops.analyzerHelpers.topCpuProcess')}"\n cat /proc/$PID/cmdline | tr '\\0' ' '\n echo ""\nfi\n`,
|
||||
@@ -62,12 +62,12 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
// 内存告警
|
||||
if (metric.includes('mem') || metric.includes('ram')) {
|
||||
return {
|
||||
rootCause: `检测到 ${target} 内存使用率达到 ${alert.currentValue},接近或超过阈值 ${alert.threshold}。常见原因:1) 应用内存泄漏,对象未被正确释放;2) 缓存配置过大;3) 数据库连接池未及时释放。`,
|
||||
rootCause: i18n.t('aiops.analyzer.memRootCause', { target, value: alert.currentValue, threshold: alert.threshold }),
|
||||
impact: isCritical
|
||||
? `内存即将耗尽可能触发 OOM Killer,导致关键进程被强制终止,服务中断风险极高。`
|
||||
: `内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。`,
|
||||
? i18n.t('aiops.analyzer.memImpactCritical')
|
||||
: i18n.t('aiops.analyzer.memImpactWarning'),
|
||||
recommendations: [
|
||||
`检查 ${target} 上的内存占用最高的进程`,
|
||||
i18n.t('aiops.analyzer.memRecCheck', { target }),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
@@ -80,12 +80,12 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
// 磁盘告警
|
||||
if (metric.includes('disk') || metric.includes('space')) {
|
||||
return {
|
||||
rootCause: `检测到 ${target} 磁盘使用率达到 ${alert.currentValue},超过阈值 ${alert.threshold}。最常见原因:1) 日志文件未配置轮转/清理;2) 临时文件堆积;3) 数据库数据文件膨胀。`,
|
||||
rootCause: i18n.t('aiops.analyzer.diskRootCause', { target, value: alert.currentValue, threshold: alert.threshold }),
|
||||
impact: isCritical
|
||||
? `磁盘空间不足可能导致服务无法写入数据/日志,数据库可能崩溃,文件系统变只读,影响范围极大。`
|
||||
: `磁盘空间告警,如不及时清理可能导致服务异常。`,
|
||||
? i18n.t('aiops.analyzer.diskImpactCritical')
|
||||
: i18n.t('aiops.analyzer.diskImpactWarning'),
|
||||
recommendations: [
|
||||
`清理 ${target} 上 30 天前的日志文件`,
|
||||
i18n.t('aiops.analyzer.diskRecClean', { target }),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
@@ -99,12 +99,12 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
// 网络告警
|
||||
if (metric.includes('net') || metric.includes('latency') || metric.includes('bandwidth')) {
|
||||
return {
|
||||
rootCause: `检测到 ${target} 网络指标异常(当前值 ${alert.currentValue}),可能原因:1) 上游依赖服务响应变慢;2) 网络带宽打满;3) DNS 解析延迟;4) 连接数达到上限。`,
|
||||
rootCause: i18n.t('aiops.analyzer.netRootCause', { target, value: alert.currentValue }),
|
||||
impact: isCritical
|
||||
? `网络异常将导致所有经过该节点的请求超时,影响所有上游业务的可用性。`
|
||||
: `网络延迟偏高,可能影响用户体验,建议排查网络链路。`,
|
||||
? i18n.t('aiops.analyzer.netImpactCritical')
|
||||
: i18n.t('aiops.analyzer.netImpactWarning'),
|
||||
recommendations: [
|
||||
`检查 ${target} 的网络连接和带宽使用情况`,
|
||||
i18n.t('aiops.analyzer.netRecCheck', { target }),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
@@ -117,12 +117,12 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
// 服务可用性告警
|
||||
if (metric.includes('service') || metric.includes('up') || metric.includes('avail')) {
|
||||
return {
|
||||
rootCause: `检测到 ${target} 服务不可用(指标 ${alert.metric} = ${alert.currentValue})。可能原因:1) 进程崩溃或被 OOM Killer 终止;2) 端口被占用或监听异常;3) 健康检查端点返回错误;4) 配置文件错误导致启动失败。`,
|
||||
rootCause: i18n.t('aiops.analyzer.serviceRootCause', { target, metric: alert.metric, value: alert.currentValue }),
|
||||
impact: isCritical
|
||||
? `服务完全不可用,所有依赖该服务的业务功能将中断,需要立即处理。`
|
||||
: `服务可用性下降,部分功能可能受影响。`,
|
||||
? i18n.t('aiops.analyzer.serviceImpactCritical')
|
||||
: i18n.t('aiops.analyzer.serviceImpactWarning'),
|
||||
recommendations: [
|
||||
`立即检查 ${target} 的服务状态: systemctl status <service>`,
|
||||
i18n.t('aiops.analyzer.serviceRecCheck', { target }),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
i18n.t('aiops.analysis.checkAbnormalTasks'),
|
||||
@@ -135,12 +135,12 @@ export function generateAIAnalysis(alert: AlertItem): AIAnalysis {
|
||||
|
||||
// 默认/通用分析
|
||||
return {
|
||||
rootCause: `检测到 ${target} 触发告警「${alert.name}」,当前指标值 ${alert.currentValue} 超过阈值 ${alert.threshold}。建议进一步排查具体指标数据和相关日志以确定根因。`,
|
||||
rootCause: i18n.t('aiops.analyzer.defaultRootCause', { target, name: alert.name, value: alert.currentValue, threshold: alert.threshold }),
|
||||
impact: isCritical
|
||||
? `该告警级别为严重,可能影响业务正常运行,建议优先处理。`
|
||||
: `该告警需要关注,持续恶化可能影响系统稳定性。`,
|
||||
? i18n.t('aiops.analyzer.defaultImpactCritical')
|
||||
: i18n.t('aiops.analyzer.defaultImpactWarning'),
|
||||
recommendations: [
|
||||
`查看 ${target} 的监控仪表盘,确认指标趋势`,
|
||||
i18n.t('aiops.analyzer.defaultRecDashboard', { target }),
|
||||
i18n.t('aiops.analysis.checkSystemLogs'),
|
||||
i18n.t('aiops.analysis.checkSystemLogs'),
|
||||
i18n.t('aiops.analysis.checkSystemLogs'),
|
||||
@@ -169,7 +169,8 @@ export function mapAlertEvent(event: JsonData): AlertItem {
|
||||
const diffMin = Math.max(1, Math.round((endTime.getTime() - startTime.getTime()) / 60000));
|
||||
const duration = diffMin >= 60 ? i18n.t('aiops.durationHM', { hours: Math.floor(diffMin / 60), mins: diffMin % 60 }) : i18n.t('aiops.durationM', { mins: diffMin });
|
||||
|
||||
const startedAt = startTime.toLocaleString('zh-CN', { hour12: false });
|
||||
const locale = i18n.language || 'zh-CN';
|
||||
const startedAt = startTime.toLocaleString(locale, { hour12: false });
|
||||
|
||||
return {
|
||||
id: String(event.id),
|
||||
@@ -182,7 +183,7 @@ export function mapAlertEvent(event: JsonData): AlertItem {
|
||||
currentValue,
|
||||
duration,
|
||||
startedAt,
|
||||
description: event.message && event.message !== `告警事件 ${event.id}`
|
||||
description: event.message && event.message !== i18n.t('aiops.analyzer.defaultEvent', { id: event.id })
|
||||
? event.message
|
||||
: event.rule?.description || `${event.rule_name || i18n.t('monitor.hostDashboard.alert')}: ${event.target} ${i18n.t('common.currentValue')} ${currentValue}`,
|
||||
};
|
||||
|
||||
@@ -8728,6 +8728,34 @@
|
||||
"reachable": "reachable",
|
||||
"cost": {
|
||||
"aiInsight": "AI Deep Insight"
|
||||
},
|
||||
"analyzer": {
|
||||
"cpuRootCause": "Detected CPU usage on {{target}} reached {{value}}, exceeding threshold {{threshold}}. Possible causes: 1) A process has an infinite loop or high computational load; 2) Frequent GC triggers (Java/Go apps); 3) Sudden traffic surge exceeding processing capacity.",
|
||||
"cpuImpactCritical": "Sustained high CPU load will significantly increase service response latency, potentially triggering cascading failures affecting all services dependent on this node.",
|
||||
"cpuImpactWarning": "CPU usage is elevated, which may slow down some request processing. Investigate promptly to prevent further degradation.",
|
||||
"cpuRecLogin": "Log in to {{target}} and run top/htop to identify high-CPU processes",
|
||||
"cpuRecScale": "Consider temporary scaling out or diverting traffic to other nodes",
|
||||
"memRootCause": "Detected memory usage on {{target}} reached {{value}}, approaching or exceeding threshold {{threshold}}. Common causes: 1) Application memory leak, objects not properly released; 2) Cache configured too large; 3) Database connection pool not released in time.",
|
||||
"memImpactCritical": "Memory exhaustion may trigger OOM Killer, forcibly terminating critical processes with extremely high service disruption risk.",
|
||||
"memImpactWarning": "Memory continues to grow, may cause OOM in the long term. Investigate memory usage as soon as possible.",
|
||||
"memRecCheck": "Check the highest memory-consuming processes on {{target}}",
|
||||
"diskRootCause": "Detected disk usage on {{target}} reached {{value}}, exceeding threshold {{threshold}}. Most common causes: 1) Log files without rotation/cleanup configured; 2) Temporary file accumulation; 3) Database data file bloat.",
|
||||
"diskImpactCritical": "Insufficient disk space may prevent services from writing data/logs, database may crash, filesystem may become read-only, with widespread impact.",
|
||||
"diskImpactWarning": "Disk space alert. Failure to clean up promptly may cause service anomalies.",
|
||||
"diskRecClean": "Clean up log files older than 30 days on {{target}}",
|
||||
"netRootCause": "Detected network metric anomaly on {{target}} (current value {{value}}). Possible causes: 1) Upstream dependency services responding slowly; 2) Network bandwidth saturated; 3) DNS resolution latency; 4) Connection limit reached.",
|
||||
"netImpactCritical": "Network anomalies will cause all requests through this node to time out, affecting availability of all upstream services.",
|
||||
"netImpactWarning": "Network latency is elevated, may affect user experience. Investigate the network path.",
|
||||
"netRecCheck": "Check network connections and bandwidth usage on {{target}}",
|
||||
"serviceRootCause": "Detected service unavailable on {{target}} (metric {{metric}} = {{value}}). Possible causes: 1) Process crashed or killed by OOM Killer; 2) Port occupied or listening abnormally; 3) Health check endpoint returning errors; 4) Configuration errors causing startup failure.",
|
||||
"serviceImpactCritical": "Service is completely unavailable. All business functions dependent on this service will be disrupted. Immediate action required.",
|
||||
"serviceImpactWarning": "Service availability degraded. Some functions may be affected.",
|
||||
"serviceRecCheck": "Immediately check service status on {{target}}: systemctl status <service>",
|
||||
"defaultRootCause": "Detected alert triggered on {{target}}: \"{{name}}\", current metric value {{value}} exceeds threshold {{threshold}}. Further investigation of specific metric data and related logs is recommended to determine root cause.",
|
||||
"defaultImpactCritical": "This alert severity is critical and may affect normal business operations. Prioritized handling is recommended.",
|
||||
"defaultImpactWarning": "This alert requires attention. Continued deterioration may affect system stability.",
|
||||
"defaultRecDashboard": "Check the monitoring dashboard for {{target}} to confirm metric trends",
|
||||
"defaultEvent": "Alert event {{id}}"
|
||||
}
|
||||
},
|
||||
"breadcrumb": {
|
||||
|
||||
@@ -8728,6 +8728,34 @@
|
||||
"reachable": "可达",
|
||||
"cost": {
|
||||
"aiInsight": "AI 深度解读"
|
||||
},
|
||||
"analyzer": {
|
||||
"cpuRootCause": "检测到 {{target}} 上 CPU 使用率达到 {{value}},持续超过阈值 {{threshold}}。可能原因:1) 某进程存在死循环或高计算负载;2) GC 频繁触发(Java/Go 应用);3) 业务流量突增导致处理能力不足。",
|
||||
"cpuImpactCritical": "CPU 持续高负载将导致服务响应延迟显著增加,严重时可能触发雪崩效应,影响全部依赖该节点的业务。",
|
||||
"cpuImpactWarning": "CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。",
|
||||
"cpuRecLogin": "登录 {{target}} 执行 top/htop 定位高 CPU 进程",
|
||||
"cpuRecScale": "考虑临时扩容或将部分流量调度到其他节点",
|
||||
"memRootCause": "检测到 {{target}} 内存使用率达到 {{value}},接近或超过阈值 {{threshold}}。常见原因:1) 应用内存泄漏,对象未被正确释放;2) 缓存配置过大;3) 数据库连接池未及时释放。",
|
||||
"memImpactCritical": "内存即将耗尽可能触发 OOM Killer,导致关键进程被强制终止,服务中断风险极高。",
|
||||
"memImpactWarning": "内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。",
|
||||
"memRecCheck": "检查 {{target}} 上的内存占用最高的进程",
|
||||
"diskRootCause": "检测到 {{target}} 磁盘使用率达到 {{value}},超过阈值 {{threshold}}。最常见原因:1) 日志文件未配置轮转/清理;2) 临时文件堆积;3) 数据库数据文件膨胀。",
|
||||
"diskImpactCritical": "磁盘空间不足可能导致服务无法写入数据/日志,数据库可能崩溃,文件系统变只读,影响范围极大。",
|
||||
"diskImpactWarning": "磁盘空间告警,如不及时清理可能导致服务异常。",
|
||||
"diskRecClean": "清理 {{target}} 上 30 天前的日志文件",
|
||||
"netRootCause": "检测到 {{target}} 网络指标异常(当前值 {{value}}),可能原因:1) 上游依赖服务响应变慢;2) 网络带宽打满;3) DNS 解析延迟;4) 连接数达到上限。",
|
||||
"netImpactCritical": "网络异常将导致所有经过该节点的请求超时,影响所有上游业务的可用性。",
|
||||
"netImpactWarning": "网络延迟偏高,可能影响用户体验,建议排查网络链路。",
|
||||
"netRecCheck": "检查 {{target}} 的网络连接和带宽使用情况",
|
||||
"serviceRootCause": "检测到 {{target}} 服务不可用(指标 {{metric}} = {{value}})。可能原因:1) 进程崩溃或被 OOM Killer 终止;2) 端口被占用或监听异常;3) 健康检查端点返回错误;4) 配置文件错误导致启动失败。",
|
||||
"serviceImpactCritical": "服务完全不可用,所有依赖该服务的业务功能将中断,需要立即处理。",
|
||||
"serviceImpactWarning": "服务可用性下降,部分功能可能受影响。",
|
||||
"serviceRecCheck": "立即检查 {{target}} 的服务状态: systemctl status <service>",
|
||||
"defaultRootCause": "检测到 {{target}} 触发告警「{{name}}」,当前指标值 {{value}} 超过阈值 {{threshold}}。建议进一步排查具体指标数据和相关日志以确定根因。",
|
||||
"defaultImpactCritical": "该告警级别为严重,可能影响业务正常运行,建议优先处理。",
|
||||
"defaultImpactWarning": "该告警需要关注,持续恶化可能影响系统稳定性。",
|
||||
"defaultRecDashboard": "查看 {{target}} 的监控仪表盘,确认指标趋势",
|
||||
"defaultEvent": "告警事件 {{id}}"
|
||||
}
|
||||
},
|
||||
"breadcrumb": {
|
||||
|
||||
Reference in new issue
Block a user