Files
aiops/backend/internal/models/metrics_kline.go
T

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"
// 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
}