chore: 重新编译前端产物(补装CodeMirror依赖)
This commit is contained in:
1 parent
23e9e3da62
commit
4e384ca401
115 files changed
+147
-147
No files matched your search
@@ -0,0 +1,57 @@
|
||||
import{j as s,r as l}from"./vendor-codemirror-B1SGo4xl.js";import{C as b,b as v,c as w,a as C}from"./card-BIfzBCEy.js";import{B as y}from"./badge-CGJlVD3L.js";import{q as z,B as A,D as O,a as U,b as B,c as J,d as E}from"./index-Dungj95X.js";import{a as L}from"./alert-v1WaPeEX.js";import{a as G}from"./ai-D8ZhLQOB.js";import{aD as R,aA as g,L as $,ab as D,aa as F,y as f,F as H,r as S,z as P,w as K,az as q,l as _,h as X,b as Q,a as W}from"./vendor-icons-DmqcWdzX.js";function Y(e){const c=(e.metric||"").toLowerCase(),t=e.source||"目标主机",a=e.severity==="critical";return c.includes("cpu")?{rootCause:`检测到 ${t} 上 CPU 使用率达到 ${e.currentValue},持续超过阈值 ${e.threshold}。可能原因:1) 某进程存在死循环或高计算负载;2) GC 频繁触发(Java/Go 应用);3) 业务流量突增导致处理能力不足。`,impact:a?"CPU 持续高负载将导致服务响应延迟显著增加,严重时可能触发雪崩效应,影响全部依赖该节点的业务。":"CPU 使用率偏高,可能导致部分请求处理变慢,建议及时排查避免进一步恶化。",recommendations:[`登录 ${t} 执行 top/htop 定位高 CPU 进程`,"检查是否有异常定时任务或批处理任务在运行","考虑临时扩容或将部分流量调度到其他节点","优化应用代码,排查是否存在低效算法或资源泄漏"],autoFixScript:`#!/bin/bash
|
||||
# CPU 高负载诊断脚本 - ${t}
|
||||
echo "===== CPU TOP 10 进程 ====="
|
||||
ps aux --sort=-%cpu | head -11
|
||||
echo ""
|
||||
echo "===== 系统负载 ====="
|
||||
uptime
|
||||
echo ""
|
||||
echo "===== 高 CPU 进程详情 ====="
|
||||
PID=$(ps aux --sort=-%cpu | sed -n '2p' | awk '{print $2}')
|
||||
if [ -n "$PID" ]; then
|
||||
echo "最高 CPU 进程: PID=$PID"
|
||||
cat /proc/$PID/cmdline | tr '\\0' ' '
|
||||
echo ""
|
||||
fi
|
||||
`,similarCases:0,confidence:0}:c.includes("mem")||c.includes("ram")?{rootCause:`检测到 ${t} 内存使用率达到 ${e.currentValue},接近或超过阈值 ${e.threshold}。常见原因:1) 应用内存泄漏,对象未被正确释放;2) 缓存配置过大;3) 数据库连接池未及时释放。`,impact:a?"内存即将耗尽可能触发 OOM Killer,导致关键进程被强制终止,服务中断风险极高。":"内存持续增长,长期可能导致 OOM,建议尽快排查内存使用情况。",recommendations:[`检查 ${t} 上的内存占用最高的进程`,"如果是 Java 应用,检查 JVM 堆内存配置和 GC 日志","排查是否存在内存泄漏,必要时生成堆转储分析","调整缓存大小限制或增加交换分区"],similarCases:0,confidence:0}:c.includes("disk")||c.includes("space")?{rootCause:`检测到 ${t} 磁盘使用率达到 ${e.currentValue},超过阈值 ${e.threshold}。最常见原因:1) 日志文件未配置轮转/清理;2) 临时文件堆积;3) 数据库数据文件膨胀。`,impact:a?"磁盘空间不足可能导致服务无法写入数据/日志,数据库可能崩溃,文件系统变只读,影响范围极大。":"磁盘空间告警,如不及时清理可能导致服务异常。",recommendations:[`清理 ${t} 上 30 天前的日志文件`,"检查并清理临时目录 /tmp、/var/tmp","配置 logrotate 日志轮转策略","考虑扩容磁盘或将数据迁移到对象存储"],autoFixScript:`#!/bin/bash
|
||||
# 磁盘清理脚本 - ${t}
|
||||
echo "===== 清理前磁盘使用 ====="
|
||||
df -h /
|
||||
echo ""
|
||||
echo "===== 清理 30 天前日志 ====="
|
||||
find /var/log -name "*.log" -mtime +30 -delete 2>/dev/null
|
||||
find /var/log -name "*.gz" -mtime +30 -delete 2>/dev/null
|
||||
echo ""
|
||||
echo "===== 清理系统缓存 ====="
|
||||
journalctl --vacuum-time=7d 2>/dev/null
|
||||
echo ""
|
||||
echo "===== 清理后磁盘使用 ====="
|
||||
df -h /
|
||||
`,similarCases:0,confidence:0}:c.includes("net")||c.includes("latency")||c.includes("bandwidth")?{rootCause:`检测到 ${t} 网络指标异常(当前值 ${e.currentValue}),可能原因:1) 上游依赖服务响应变慢;2) 网络带宽打满;3) DNS 解析延迟;4) 连接数达到上限。`,impact:a?"网络异常将导致所有经过该节点的请求超时,影响所有上游业务的可用性。":"网络延迟偏高,可能影响用户体验,建议排查网络链路。",recommendations:[`检查 ${t} 的网络连接和带宽使用情况`,"排查上游依赖服务的健康状态和响应时间","检查防火墙规则是否有限速或异常丢弃","考虑启用熔断/降级机制保障核心链路"],similarCases:0,confidence:0}:c.includes("service")||c.includes("up")||c.includes("avail")?{rootCause:`检测到 ${t} 服务不可用(指标 ${e.metric} = ${e.currentValue})。可能原因:1) 进程崩溃或被 OOM Killer 终止;2) 端口被占用或监听异常;3) 健康检查端点返回错误;4) 配置文件错误导致启动失败。`,impact:a?"服务完全不可用,所有依赖该服务的业务功能将中断,需要立即处理。":"服务可用性下降,部分功能可能受影响。",recommendations:[`立即检查 ${t} 的服务状态: systemctl status <service>`,"查看服务日志排查崩溃原因","检查端口占用和监听状态: ss -tlnp","必要时重启服务并监控恢复情况"],autoFixScript:`#!/bin/bash
|
||||
# 服务恢复脚本 - ${t}
|
||||
echo "===== 检查服务状态 ====="
|
||||
systemctl list-units --state=failed
|
||||
echo ""
|
||||
echo "===== 检查端口监听 ====="
|
||||
ss -tlnp | grep -E ':(80|443|8080|3306|6379|9090)'
|
||||
echo ""
|
||||
echo "===== 重启失败服务 ====="
|
||||
systemctl reset-failed
|
||||
`,similarCases:0,confidence:0}:{rootCause:`检测到 ${t} 触发告警「${e.name}」,当前指标值 ${e.currentValue} 超过阈值 ${e.threshold}。建议进一步排查具体指标数据和相关日志以确定根因。`,impact:a?"该告警级别为严重,可能影响业务正常运行,建议优先处理。":"该告警需要关注,持续恶化可能影响系统稳定性。",recommendations:[`查看 ${t} 的监控仪表盘,确认指标趋势`,"检查对应时间段的系统日志和应用日志","关联同时间段的其他告警,排查是否有连锁反应","若确认误报,调整告警规则阈值或持续时间"],similarCases:0,confidence:0}}function Z(e){const c=e.rule?.expression||"",t=c.match(/([\w_]+)\s*[><=!]+\s*([\d.]+)/),a=t?t[1]:c||"unknown",n=t?t[2]+"%":"-",r=e.value??0,d=a.includes("usage")||a.includes("cpu")||a.includes("disk")||a.includes("mem")?r.toFixed(1)+"%":r.toFixed(2),x=e.resolved_at?new Date(e.resolved_at):new Date,i=new Date(e.started_at),p=Math.max(1,Math.round((x.getTime()-i.getTime())/6e4)),h=p>=60?`${Math.floor(p/60)}小时${p%60}分钟`:`${p}分钟`,u=i.toLocaleString("zh-CN",{hour12:!1});return{id:String(e.id),name:e.rule_name||e.rule?.name||"未知告警",severity:e.severity==="critical"?"critical":e.severity==="warning"?"warning":"info",status:e.status==="firing"?"active":"resolved",source:e.target||"未知目标",metric:a,threshold:n,currentValue:d,duration:h,startedAt:u,description:e.message&&e.message!==`告警事件 ${e.id}`?e.message:e.rule?.description||`${e.rule_name||"告警"}: ${e.target} 当前值 ${d}`}}function ss(e){switch(e){case"critical":return"bg-red-500/10 text-red-400 border-red-500/30";case"warning":return"bg-amber-500/10 text-amber-400 border-amber-500/30";default:return"bg-blue-500/10 text-blue-400 border-blue-500/30"}}function es({selectedAlert:e,isAnalyzing:c,analysis:t,onAutoFix:a}){return s.jsxs(b,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:18:5",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:19:7",className:"border-b border-slate-700 pb-3",children:s.jsxs(w,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:20:9",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(R,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:21:11",className:"h-5 w-5 text-purple-400"}),"AI 分析结果"]})}),s.jsx(z,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:25:7",className:"flex-1",children:s.jsx(C,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:26:9",className:"p-4",children:e?c?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:33:13",className:"flex flex-col items-center justify-center h-64",children:[s.jsx($,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:34:15",className:"h-8 w-8 animate-spin text-purple-400 mb-4"}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:35:15",className:"text-slate-400",children:"AI正在分析告警根因..."}),s.jsx("p",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:36:15",className:"text-xs text-slate-500 mt-2",children:"正在关联日志、指标和历史案例"})]}):t?s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:39:13",className:"space-y-4",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:41:15",className:"flex items-center justify-between p-3 bg-purple-500/10 rounded-lg border border-purple-500/30",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:42:17",className:"flex items-center gap-2",children:[s.jsx(g,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:43:19",className:"h-5 w-5 text-purple-400"}),s.jsx("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:44:19",className:"text-slate-300",children:"分析置信度"})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:46:17",className:"flex items-center gap-2",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:47:19",className:"w-32 h-2 bg-slate-700 rounded-full overflow-hidden",children:s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:48:21",className:"h-full bg-gradient-to-r from-purple-500 to-pink-500",style:{width:`${t.confidence}%`}})}),s.jsxs("span",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:53:19",className:"text-purple-400 font-bold",children:[t.confidence,"%"]})]})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:58:15",className:"space-y-2",children:[s.jsxs("h4",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:59:17",className:"text-sm font-medium text-slate-300 flex items-center gap-2",children:[s.jsx(D,{"code-path":"src/components/aiops/AIAnalysisResult.tsx:60:19",className:"h-4 w-4 text-red-400"}),"根因分析"]}),s.jsx("div",{"code-path":"src/components/aiops/AIAnalysisResult.tsx:63:17",className:"p-3 bg-slate-900 rounded-lg border border-slate-700",childre
Line truncated
|
||||
|
||||
告警名称:${o.name}
|
||||
严重程度:${o.severity}
|
||||
目标:${o.source}
|
||||
指标:${o.metric} = ${o.currentValue}(阈值 ${o.threshold})
|
||||
持续:${o.duration}
|
||||
描述:${o.description}
|
||||
|
||||
返回 JSON 格式(字段名用 snake_case):
|
||||
{
|
||||
"root_cause": "根因分析(2-3句)",
|
||||
"impact": "影响评估(1-2句)",
|
||||
"recommendations": ["建议1", "建议2", "建议3"],
|
||||
"auto_fix_script": "#!/bin/bash\\n...\\n(可选的自动修复脚本,无则 null)",
|
||||
"similar_cases": 数字(类似案例数预估),
|
||||
"confidence": 数字(0-100 置信度)
|
||||
}`,N=await G.chat([{role:"user",content:M}]),I=N?.content||N?.message?.content||"";i(I?as(I,m):m)}catch{i(m)}finally{d(!1)}},k=()=>{h(!0)},V=o=>{switch(o){case"critical":return s.jsx(W,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:128:16",className:"h-4 w-4 text-red-400"});case"warning":return s.jsx(D,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:130:16",className:"h-4 w-4 text-amber-400"});default:return s.jsx(f,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:132:16",className:"h-4 w-4 text-blue-400"})}};return s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:137:5",className:"space-y-6",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:139:7",className:"flex items-center justify-between",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:140:9",className:"flex items-center gap-3",children:[s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:141:11",className:"w-10 h-10 rounded-lg bg-gradient-to-br from-amber-500 to-orange-500 flex items-center justify-center",children:s.jsx(g,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:142:13",className:"h-5 w-5 text-white"})}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:144:11",children:[s.jsx("h1",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:145:13",className:"text-2xl font-bold text-slate-100",children:"AI 告警智能分析"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:146:13",className:"text-sm text-slate-500",children:"基于大模型的告警根因分析和自动修复建议"})]})]}),s.jsx("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:149:9",className:"flex items-center gap-2",children:s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:150:11",variant:"outline",className:"border-emerald-500/30 text-emerald-400 bg-emerald-500/10",children:[s.jsx(R,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:151:13",className:"h-3 w-3 mr-1"}),"AI 引擎运行中"]})})]}),s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:157:7",className:"grid grid-cols-2 gap-6 h-[calc(100vh-200px)]",children:[s.jsxs(b,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:159:9",className:"bg-slate-800 border-slate-700 flex flex-col",children:[s.jsx(v,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:160:11",className:"border-b border-slate-700 pb-3",children:s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:161:13",className:"flex items-center justify-between",children:[s.jsxs(w,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:162:15",className:"text-slate-100 flex items-center gap-2",children:[s.jsx(_,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:163:17",className:"h-5 w-5 text-amber-400"}),"活跃告警"]}),s.jsxs(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:166:15",className:"bg-red-500/10 text-red-400 border-red-500/30",children:[e.filter(o=>o.status==="active").length," 个活跃"]})]})}),s.jsx(z,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:171:11",className:"flex-1",children:s.jsx(C,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:172:13",className:"p-4 space-y-3",children:t?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:174:17",className:"flex flex-col items-center justify-center h-32",children:[s.jsx($,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:175:19",className:"h-6 w-6 animate-spin text-slate-500 mb-2"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:176:19",className:"text-sm text-slate-500",children:"加载告警数据..."})]}):e.length===0?s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:179:17",className:"flex flex-col items-center justify-center h-32 text-slate-500",children:[s.jsx(f,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:180:19",className:"h-8 w-8 mb-2 opacity-50"}),s.jsx("p",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:181:19",className:"text-sm",children:"暂无告警事件"})]}):e.map(o=>s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:185:17",className:`p-4 rounded-lg border cursor-pointer transition-all ${n?.id===o.id?"border-purple-500 bg-purple-500/10":"border-slate-700 bg-slate-800/50 hover:border-slate-600"}`,onClick:()=>T(o),children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:194:19",className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:195:21",className:"flex items-center gap-2",children:[V(o.severity),s.jsx("span",{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:197:23",className:"font-medium text-slate-100",children:o.name})]}),s.jsx(y,{"code-path":"src/components/aiops/AIAlertAnalyzer.tsx:199:21",variant:"outline",className:ss(o.severity),children:o.severity==="critical"?"严重":o.severity==="warning"?"警告":"提示"})]}),s.jsx("div",{"code-path":"src
Line truncated
|
||||
Reference in new issue
Block a user