feat: Redis热数据+K线聚合+Dashboard MySQL指标修复

This commit is contained in:
attacker committed 2026-06-18 08:03:49 +00:00
1 parent b8b1a3d5f6
commit a843ab7b00
9 files changed
+311 -12

No files matched your search

+38
View File
@@ -0,0 +1,38 @@
package models
import "time"
// MetricsKline 指标K线聚合数据(由 Redis 热数据聚合到 MySQL)// Logan.Li
type MetricsKline struct {
ID uint `gorm:"primarykey" json:"id"`
Hostname string `gorm:"size:255;index:idx_kline;not null" json:"hostname"`
Metric string `gorm:"size:32;index:idx_kline;not null" json:"metric"` // cpu / mem / load1
Interval string `gorm:"size:8;index:idx_kline;not null" json:"interval"` // 1m / 3m / 1h / 6h / 1d
Open float64 `gorm:"type:decimal(10,2)" json:"open"`
High float64 `gorm:"type:decimal(10,2)" json:"high"`
Low float64 `gorm:"type:decimal(10,2)" json:"low"`
Close float64 `gorm:"type:decimal(10,2)" json:"close"`
Avg float64 `gorm:"type:decimal(10,2)" json:"avg"`
Count int `json:"count"`
BucketTime time.Time `gorm:"index:idx_kline;not null" json:"bucket_time"`
CreatedAt time.Time `json:"created_at"`
}
func (MetricsKline) TableName() string {
return "metrics_klines"
}
// AggregateKlineReq 聚合请求体
type AggregateKlineReq struct {
Hostname string `json:"hostname" binding:"required"`
Metric string `json:"metric" binding:"required"` // cpu / mem / load1
}
// KlineQueryReq K线查询参数(Query 参数)
type KlineQueryReq 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
}