feat(运维监控): 增强监控功能和健康评分系统
后端改进: - 新增健康评分计算服务(ops_health_score.go) - 添加分布式锁支持(ops_advisory_lock.go) - 优化指标采集和聚合逻辑 - 新增运维指标采集间隔配置(60-3600秒) - 移除未使用的WebSocket查询token认证中间件 - 改进清理服务和告警评估逻辑 前端改进: - 简化OpsDashboard组件结构 - 完善国际化文本(中英文) - 新增运维监控相关API类型定义 - 添加运维指标采集间隔设置界面 - 优化错误详情模态框 测试: - 添加健康评分单元测试 - 更新API契约测试
This commit is contained in:
@@ -1733,8 +1733,10 @@ export default {
|
||||
redis: 'Redis',
|
||||
goroutines: 'Goroutines',
|
||||
jobs: 'Jobs',
|
||||
jobsHelp: 'Click “Details” to view job heartbeats and recent errors',
|
||||
active: 'active',
|
||||
idle: 'idle',
|
||||
waiting: 'waiting',
|
||||
ok: 'ok',
|
||||
lastRun: 'last_run:',
|
||||
lastSuccess: 'last_success:',
|
||||
@@ -1770,12 +1772,50 @@ export default {
|
||||
errorsSla: 'Errors (SLA scope)',
|
||||
upstreamExcl429529: 'Upstream (excl 429/529)',
|
||||
failedToLoadData: 'Failed to load ops data.',
|
||||
failedToLoadOverview: 'Failed to load overview',
|
||||
failedToLoadThroughputTrend: 'Failed to load throughput trend',
|
||||
failedToLoadLatencyHistogram: 'Failed to load latency histogram',
|
||||
failedToLoadErrorTrend: 'Failed to load error trend',
|
||||
failedToLoadErrorDistribution: 'Failed to load error distribution',
|
||||
failedToLoadErrorDetail: 'Failed to load error detail',
|
||||
retryFailed: 'Retry failed',
|
||||
tpsK: 'TPS (K)',
|
||||
top: 'Top:',
|
||||
throughputTrend: 'Throughput Trend',
|
||||
latencyHistogram: 'Latency Histogram',
|
||||
errorTrend: 'Error Trend',
|
||||
errorDistribution: 'Error Distribution',
|
||||
// Health Score & Diagnosis
|
||||
health: 'Health',
|
||||
healthCondition: 'Health Condition',
|
||||
healthHelp: 'Overall system health score based on SLA, error rate, and resource usage',
|
||||
healthyStatus: 'Healthy',
|
||||
riskyStatus: 'At Risk',
|
||||
idleStatus: 'Idle',
|
||||
diagnosis: {
|
||||
title: 'Smart Diagnosis',
|
||||
footer: 'Automated diagnostic suggestions based on current metrics',
|
||||
idle: 'System is currently idle',
|
||||
idleImpact: 'No active traffic',
|
||||
upstreamCritical: 'Upstream error rate critically high ({rate}%)',
|
||||
upstreamCriticalImpact: 'May affect many user requests',
|
||||
upstreamHigh: 'Upstream error rate elevated ({rate}%)',
|
||||
upstreamHighImpact: 'Recommend checking upstream service status',
|
||||
slaCritical: 'SLA critically below target ({sla}%)',
|
||||
slaCriticalImpact: 'User experience severely degraded',
|
||||
slaLow: 'SLA below target ({sla}%)',
|
||||
slaLowImpact: 'Service quality needs attention',
|
||||
errorHigh: 'Error rate too high ({rate}%)',
|
||||
errorHighImpact: 'Many requests failing',
|
||||
errorElevated: 'Error rate elevated ({rate}%)',
|
||||
errorElevatedImpact: 'Recommend checking error logs',
|
||||
healthCritical: 'Overall health score critically low ({score})',
|
||||
healthCriticalImpact: 'Multiple metrics may be degraded; prioritize error rate and latency investigation',
|
||||
healthLow: 'Overall health score low ({score})',
|
||||
healthLowImpact: 'May indicate minor instability; monitor SLA and error rates',
|
||||
healthy: 'All system metrics normal',
|
||||
healthyImpact: 'Service running stable'
|
||||
},
|
||||
// Error Log
|
||||
errorLog: {
|
||||
timeId: 'Time / ID',
|
||||
@@ -2069,7 +2109,21 @@ export default {
|
||||
throughputTrend: 'Requests/QPS + Tokens/TPS in the selected window.',
|
||||
latencyHistogram: 'Latency distribution (duration_ms) for successful requests.',
|
||||
errorTrend: 'Error counts over time (SLA scope excludes business limits; upstream excludes 429/529).',
|
||||
errorDistribution: 'Error distribution by status code.'
|
||||
errorDistribution: 'Error distribution by status code.',
|
||||
goroutines:
|
||||
'Number of Go runtime goroutines (lightweight threads). There is no absolute “safe” number—use your historical baseline. Heuristic: <2k is common; 2k–8k watch; >8k plus rising queue/latency often suggests blocking/leaks.',
|
||||
cpu: 'CPU usage percentage, showing system processor load.',
|
||||
memory: 'Memory usage, including used and total available memory.',
|
||||
db: 'Database connection pool status, including active, idle, and waiting connections.',
|
||||
redis: 'Redis connection pool status, showing active and idle connections.',
|
||||
jobs: 'Background job execution status, including last run time, success time, and error information.',
|
||||
qps: 'Queries Per Second (QPS) and Tokens Per Second (TPS), real-time system throughput.',
|
||||
tokens: 'Total number of tokens processed in the current time window.',
|
||||
sla: 'Service Level Agreement success rate, excluding business limits (e.g., insufficient balance, quota exceeded).',
|
||||
errors: 'Error statistics, including total errors, error rate, and upstream error rate.',
|
||||
latency: 'Request latency statistics, including p50, p90, p95, p99 percentiles.',
|
||||
ttft: 'Time To First Token, measuring the speed of first byte return in streaming responses.',
|
||||
health: 'System health score (0-100), considering SLA, error rate, and resource usage.'
|
||||
},
|
||||
charts: {
|
||||
emptyRequest: 'No requests in this window.',
|
||||
@@ -2183,7 +2237,9 @@ export default {
|
||||
queryModeHint: 'Default query mode for Ops Dashboard (auto/raw/preagg)',
|
||||
queryModeAuto: 'Auto (recommended)',
|
||||
queryModeRaw: 'Raw (most accurate, slower)',
|
||||
queryModePreagg: 'Preagg (fastest, requires aggregation)'
|
||||
queryModePreagg: 'Preagg (fastest, requires aggregation)',
|
||||
metricsInterval: 'Metrics Collection Interval (seconds)',
|
||||
metricsIntervalHint: 'How often to collect system/request metrics (60-3600 seconds)'
|
||||
},
|
||||
adminApiKey: {
|
||||
title: 'Admin API Key',
|
||||
|
||||
@@ -1878,8 +1878,10 @@ export default {
|
||||
redis: 'Redis',
|
||||
goroutines: '协程',
|
||||
jobs: '后台任务',
|
||||
jobsHelp: '点击“明细”查看任务心跳与报错信息',
|
||||
active: '活跃',
|
||||
idle: '空闲',
|
||||
waiting: '等待',
|
||||
ok: '正常',
|
||||
lastRun: '最近运行',
|
||||
lastSuccess: '最近成功',
|
||||
@@ -1898,8 +1900,8 @@ export default {
|
||||
errors: '错误',
|
||||
errorRate: '错误率:',
|
||||
upstreamRate: '上游错误率:',
|
||||
latencyDuration: '延迟 (duration_ms)',
|
||||
ttftLabel: 'TTFT (first_token_ms)',
|
||||
latencyDuration: '延迟(毫秒)',
|
||||
ttftLabel: '首字延迟(毫秒)',
|
||||
p50: 'p50',
|
||||
p90: 'p90',
|
||||
p95: 'p95',
|
||||
@@ -1915,12 +1917,50 @@ export default {
|
||||
errorsSla: '错误(SLA范围)',
|
||||
upstreamExcl429529: '上游(排除429/529)',
|
||||
failedToLoadData: '加载运维数据失败',
|
||||
tpsK: 'TPS (K)',
|
||||
failedToLoadOverview: '加载概览数据失败',
|
||||
failedToLoadThroughputTrend: '加载吞吐趋势失败',
|
||||
failedToLoadLatencyHistogram: '加载延迟分布失败',
|
||||
failedToLoadErrorTrend: '加载错误趋势失败',
|
||||
failedToLoadErrorDistribution: '加载错误分布失败',
|
||||
failedToLoadErrorDetail: '加载错误详情失败',
|
||||
retryFailed: '重试失败',
|
||||
tpsK: 'TPS(千)',
|
||||
top: '最高:',
|
||||
throughputTrend: '吞吐趋势',
|
||||
latencyHistogram: '延迟分布',
|
||||
errorTrend: '错误趋势',
|
||||
errorDistribution: '错误分布',
|
||||
// Health Score & Diagnosis
|
||||
health: '健康',
|
||||
healthCondition: '健康状况',
|
||||
healthHelp: '基于 SLA、错误率和资源使用情况的系统整体健康评分',
|
||||
healthyStatus: '健康',
|
||||
riskyStatus: '风险',
|
||||
idleStatus: '待机',
|
||||
diagnosis: {
|
||||
title: '智能诊断',
|
||||
footer: '基于当前指标的自动诊断建议',
|
||||
idle: '系统当前处于待机状态',
|
||||
idleImpact: '无活跃流量',
|
||||
upstreamCritical: '上游错误率严重偏高 ({rate}%)',
|
||||
upstreamCriticalImpact: '可能影响大量用户请求',
|
||||
upstreamHigh: '上游错误率偏高 ({rate}%)',
|
||||
upstreamHighImpact: '建议检查上游服务状态',
|
||||
slaCritical: 'SLA 严重低于目标 ({sla}%)',
|
||||
slaCriticalImpact: '用户体验严重受损',
|
||||
slaLow: 'SLA 低于目标 ({sla}%)',
|
||||
slaLowImpact: '需要关注服务质量',
|
||||
errorHigh: '错误率过高 ({rate}%)',
|
||||
errorHighImpact: '大量请求失败',
|
||||
errorElevated: '错误率偏高 ({rate}%)',
|
||||
errorElevatedImpact: '建议检查错误日志',
|
||||
healthCritical: '综合健康评分过低 ({score})',
|
||||
healthCriticalImpact: '多个指标可能同时异常,建议优先排查错误与延迟',
|
||||
healthLow: '综合健康评分偏低 ({score})',
|
||||
healthLowImpact: '可能存在轻度波动,建议关注 SLA 与错误率',
|
||||
healthy: '所有系统指标正常',
|
||||
healthyImpact: '服务运行稳定'
|
||||
},
|
||||
// Error Log
|
||||
errorLog: {
|
||||
timeId: '时间 / ID',
|
||||
@@ -2212,9 +2252,23 @@ export default {
|
||||
},
|
||||
tooltips: {
|
||||
throughputTrend: '当前窗口内的请求/QPS 与 token/TPS 趋势。',
|
||||
latencyHistogram: '成功请求的延迟分布(duration_ms)。',
|
||||
latencyHistogram: '成功请求的延迟分布(毫秒)。',
|
||||
errorTrend: '错误趋势(SLA 口径排除业务限制;上游错误率排除 429/529)。',
|
||||
errorDistribution: '按状态码统计的错误分布。'
|
||||
errorDistribution: '按状态码统计的错误分布。',
|
||||
goroutines:
|
||||
'Go 运行时的协程数量(轻量级线程)。没有绝对“安全值”,建议以历史基线为准。经验参考:<2000 常见;2000-8000 需关注;>8000 且伴随队列/延迟上升时,优先排查阻塞/泄漏。',
|
||||
cpu: 'CPU 使用率,显示系统处理器的负载情况。',
|
||||
memory: '内存使用率,包括已使用和总可用内存。',
|
||||
db: '数据库连接池状态,包括活跃连接、空闲连接和等待连接数。',
|
||||
redis: 'Redis 连接池状态,显示活跃和空闲的连接数。',
|
||||
jobs: '后台任务执行状态,包括最近运行时间、成功时间和错误信息。',
|
||||
qps: '每秒查询数(QPS)和每秒Token数(TPS),实时显示系统吞吐量。',
|
||||
tokens: '当前时间窗口内处理的总Token数量。',
|
||||
sla: '服务等级协议达成率,排除业务限制(如余额不足、配额超限)的成功请求占比。',
|
||||
errors: '错误统计,包括总错误数、错误率和上游错误率。',
|
||||
latency: '请求延迟统计,包括 p50、p90、p95、p99 等百分位数。',
|
||||
ttft: '首Token延迟(Time To First Token),衡量流式响应的首字节返回速度。',
|
||||
health: '系统健康评分(0-100),综合考虑 SLA、错误率和资源使用情况。'
|
||||
},
|
||||
charts: {
|
||||
emptyRequest: '该时间窗口内暂无请求。',
|
||||
@@ -2320,14 +2374,16 @@ export default {
|
||||
description: '启用运维监控模块,用于排障与健康可视化',
|
||||
disabled: '运维监控已关闭',
|
||||
enabled: '启用运维监控',
|
||||
enabledHint: '启用 Ops 运维监控模块(仅管理员可见)',
|
||||
enabledHint: '启用运维监控模块(仅管理员可见)',
|
||||
realtimeEnabled: '启用实时监控',
|
||||
realtimeEnabledHint: '启用实时 QPS/指标推送(WebSocket)',
|
||||
realtimeEnabledHint: '启用实时请求速率和指标推送(WebSocket)',
|
||||
queryMode: '默认查询模式',
|
||||
queryModeHint: 'Ops Dashboard 默认查询模式(auto/raw/preagg)',
|
||||
queryModeHint: '运维监控默认查询模式(自动/原始/预聚合)',
|
||||
queryModeAuto: '自动(推荐)',
|
||||
queryModeRaw: 'Raw(最准,但较慢)',
|
||||
queryModePreagg: 'Preagg(最快,需预聚合)'
|
||||
queryModeRaw: '原始(最准确,但较慢)',
|
||||
queryModePreagg: '预聚合(最快,需预聚合)',
|
||||
metricsInterval: '采集频率(秒)',
|
||||
metricsIntervalHint: '系统/请求指标采集频率(60-3600 秒)'
|
||||
},
|
||||
adminApiKey: {
|
||||
title: '管理员 API Key',
|
||||
|
||||
Reference in New Issue
Block a user