Files
aiops/backend/internal/models/metrics_aggregate.go
T
attacker 5949ec5d0c feat: Agent采集uptime, 后端持久化kernel/uptime/diskIO, 前端磁盘BPS+IOPS展示
- Agent: system.go 添加 readUptime(), SystemStat 携带 Uptime
- Backend: Server 模型新增 Kernel 字段, ReceiveReport 持久化 kernel+uptime
- Backend: /agent/latest 返回 kernel/uptime/port_info/disk_io_info/disk_total
- Frontend: 磁盘监控改为 BPS+IOPS (4张卡片), 系统信息修复内核/运行时长/监听端口/磁盘容量
- 图表单位从 MB/s 改为 KB/s, 添加 formatBPS 工具函数
2026-06-19 01:10:00 +00:00

39 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package models
import "time"
// MetricsAggregate 指标聚合数据(Redis 热数据 → MySQL 时序聚合)// Logan.Li
// 替代旧名 MetricsKline,OHLC 对监控无意义,改用 max/min/avg/p95
type MetricsAggregate struct {
ID uint `gorm:"primarykey" json:"id"`
Hostname string `gorm:"size:255;index:idx_agg;not null" json:"hostname"`
Metric string `gorm:"size:32;index:idx_agg;not null" json:"metric"` // cpu / mem / load1 / disk / net_rx / net_tx
Interval string `gorm:"size:8;index:idx_agg;not null" json:"interval"` // 1m / 5m / 1h / 6h / 1d
Avg float64 `gorm:"type:decimal(10,2)" json:"avg"`
MaxV float64 `gorm:"column:max_v;type:decimal(10,2)" json:"max"`
MinV float64 `gorm:"column:min_v;type:decimal(10,2)" json:"min"`
P95 float64 `gorm:"type:decimal(10,2)" json:"p95"`
Count int `json:"count"`
BucketTime time.Time `gorm:"index:idx_agg;not null" json:"bucket_time"`
CreatedAt time.Time `json:"created_at"`
}
func (MetricsAggregate) TableName() string {
return "monitor_metrics_aggregate"
}
// AggregateReq 聚合触发请求
type AggregateReq struct {
Hostname string `json:"hostname" binding:"required"`
Metric string `json:"metric" binding:"required"` // cpu / mem / load1
}
// AggregateQueryReq 聚合查询参数
type AggregateQueryReq struct {
Hostname string `form:"hostname" binding:"required"`
Metric string `form:"metric" binding:"required"`
Interval string `form:"interval" binding:"required"`
From string `form:"from" binding:"required"` // RFC3339
To string `form:"to" binding:"required"` // RFC3339
}