update
This commit is contained in:
1 parent
0690285147
commit
5618cd2738
154 files changed
+5021
-3161
No files matched your search
+108
-109
@@ -42,18 +42,18 @@ type MonitorTarget struct {
|
||||
OS string `gorm:"type:varchar(64);comment:操作系统" json:"os,omitempty"`
|
||||
OSVersion string `gorm:"type:varchar(64);comment:OS版本" json:"os_version,omitempty"`
|
||||
Arch string `gorm:"type:varchar(16);comment:系统架构" json:"arch,omitempty"`
|
||||
Kernel string `gorm:"type:varchar(64);comment:内核版本" json:"kernel,omitempty"`
|
||||
HostGroupID uint `gorm:"index;comment:主机组ID" json:"host_group_id,omitempty"`
|
||||
Tags string `gorm:"type:varchar(512);comment:标签JSON" json:"tags,omitempty"`
|
||||
CollectMode string `gorm:"type:varchar(16);default:'agent';comment:采集模式:agent/snmp/api" json:"collect_mode"`
|
||||
SNMPConfig string `gorm:"type:text;comment:SNMP配置JSON" json:"snmp_config,omitempty"`
|
||||
APIConfig string `gorm:"type:text;comment:API配置JSON" json:"api_config,omitempty"`
|
||||
Address string `gorm:"type:varchar(255);comment:监控地址(IP或域名)" json:"address,omitempty"`
|
||||
Protocol string `gorm:"type:varchar(32);comment:协议类型(http/https/tcp/udp/icmp/snmp)" json:"protocol,omitempty"`
|
||||
Timeout int `gorm:"default:30;comment:超时时间(秒)" json:"timeout,omitempty"`
|
||||
Config string `gorm:"type:text;comment:通用配置JSON" json:"config,omitempty"`
|
||||
Interval int `gorm:"default:60;comment:采集间隔(秒)" json:"interval"`
|
||||
Labels string `gorm:"type:varchar(512);comment:标签JSON" json:"labels,omitempty"`
|
||||
Kernel string `gorm:"type:varchar(64);comment:内核版本" json:"kernel,omitempty"`
|
||||
HostGroupID uint `gorm:"index;comment:主机组ID" json:"host_group_id,omitempty"`
|
||||
Tags string `gorm:"type:varchar(512);comment:标签JSON" json:"tags,omitempty"`
|
||||
CollectMode string `gorm:"type:varchar(16);default:'agent';comment:采集模式:agent/snmp/api" json:"collect_mode"`
|
||||
SNMPConfig string `gorm:"type:text;comment:SNMP配置JSON" json:"snmp_config,omitempty"`
|
||||
APIConfig string `gorm:"type:text;comment:API配置JSON" json:"api_config,omitempty"`
|
||||
Address string `gorm:"type:varchar(255);comment:监控地址(IP或域名)" json:"address,omitempty"`
|
||||
Protocol string `gorm:"type:varchar(32);comment:协议类型(http/https/tcp/udp/icmp/snmp)" json:"protocol,omitempty"`
|
||||
Timeout int `gorm:"default:30;comment:超时时间(秒)" json:"timeout,omitempty"`
|
||||
Config string `gorm:"type:text;comment:通用配置JSON" json:"config,omitempty"`
|
||||
Interval int `gorm:"default:60;comment:采集间隔(秒)" json:"interval"`
|
||||
Labels string `gorm:"type:varchar(512);comment:标签JSON" json:"labels,omitempty"`
|
||||
Description string `gorm:"type:varchar(256);comment:描述" json:"description,omitempty"`
|
||||
CreatedAt time.Time `gorm:"not null;index;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"`
|
||||
@@ -86,36 +86,36 @@ const (
|
||||
type DataSourceType string
|
||||
|
||||
const (
|
||||
DataSourceAgent DataSourceType = "agent" // Agent采集
|
||||
DataSourceSNMP DataSourceType = "snmp" // SNMP采集
|
||||
DataSourceAPI DataSourceType = "api" // API采集
|
||||
DataSourceAgent DataSourceType = "agent" // Agent采集
|
||||
DataSourceSNMP DataSourceType = "snmp" // SNMP采集
|
||||
DataSourceAPI DataSourceType = "api" // API采集
|
||||
DataSourcePrometheus DataSourceType = "prometheus" // Prometheus
|
||||
DataSourceZabbix DataSourceType = "zabbix" // Zabbix
|
||||
DataSourceZabbix DataSourceType = "zabbix" // Zabbix
|
||||
)
|
||||
|
||||
// MonitorMetric 监控指标定义表
|
||||
// 定义系统中所有可采集的监控指标元数据
|
||||
type MonitorMetric struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;uniqueIndex:uk_metric_name;comment:指标名称" json:"name"`
|
||||
DisplayName string `gorm:"type:varchar(128);not null;comment:显示名称" json:"display_name"`
|
||||
Description string `gorm:"type:varchar(256);comment:指标描述" json:"description,omitempty"`
|
||||
MetricType MetricType `gorm:"type:varchar(16);not null;comment:指标类型: gauge/counter/summary" json:"metric_type"`
|
||||
Unit string `gorm:"type:varchar(32);comment:单位" json:"unit,omitempty"`
|
||||
DataSource DataSourceType `gorm:"type:varchar(16);not null;comment:数据来源" json:"data_source"`
|
||||
CollectExpr string `gorm:"type:varchar(256);comment:采集表达式/OID/PromQL" json:"collect_expr,omitempty"`
|
||||
Interval int `gorm:"default:60;comment:采集间隔(秒)" json:"interval"`
|
||||
Labels string `gorm:"type:varchar(512);comment:指标标签定义JSON" json:"labels,omitempty"`
|
||||
ValueType string `gorm:"type:varchar(16);default:'float64';comment:值类型" json:"value_type"`
|
||||
Category string `gorm:"type:varchar(64);comment:指标分类" json:"category,omitempty"`
|
||||
IsDefault bool `gorm:"default:true;comment:是否默认启用" json:"is_default"`
|
||||
IsInternal bool `gorm:"default:false;comment:是否内置指标" json:"is_internal"`
|
||||
Status int `gorm:"default:1;comment:状态: 1启用 0禁用" json:"status"`
|
||||
Icon string `gorm:"type:varchar(64);comment:图标" json:"icon,omitempty"`
|
||||
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
||||
CreatedAt time.Time `gorm:"not null;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"`
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;uniqueIndex:uk_metric_name;comment:指标名称" json:"name"`
|
||||
DisplayName string `gorm:"type:varchar(128);not null;comment:显示名称" json:"display_name"`
|
||||
Description string `gorm:"type:varchar(256);comment:指标描述" json:"description,omitempty"`
|
||||
MetricType MetricType `gorm:"type:varchar(16);not null;comment:指标类型: gauge/counter/summary" json:"metric_type"`
|
||||
Unit string `gorm:"type:varchar(32);comment:单位" json:"unit,omitempty"`
|
||||
DataSource DataSourceType `gorm:"type:varchar(16);not null;comment:数据来源" json:"data_source"`
|
||||
CollectExpr string `gorm:"type:varchar(256);comment:采集表达式/OID/PromQL" json:"collect_expr,omitempty"`
|
||||
Interval int `gorm:"default:60;comment:采集间隔(秒)" json:"interval"`
|
||||
Labels string `gorm:"type:varchar(512);comment:指标标签定义JSON" json:"labels,omitempty"`
|
||||
ValueType string `gorm:"type:varchar(16);default:'float64';comment:值类型" json:"value_type"`
|
||||
Category string `gorm:"type:varchar(64);comment:指标分类" json:"category,omitempty"`
|
||||
IsDefault bool `gorm:"default:true;comment:是否默认启用" json:"is_default"`
|
||||
IsInternal bool `gorm:"default:false;comment:是否内置指标" json:"is_internal"`
|
||||
Status int `gorm:"default:1;comment:状态: 1启用 0禁用" json:"status"`
|
||||
Icon string `gorm:"type:varchar(64);comment:图标" json:"icon,omitempty"`
|
||||
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
||||
CreatedAt time.Time `gorm:"not null;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
@@ -147,7 +147,7 @@ type MetricValue struct {
|
||||
|
||||
// TableName 指定表名
|
||||
func (MetricValue) TableName() string {
|
||||
return "metric_values"
|
||||
return "monitor_metric_values"
|
||||
}
|
||||
|
||||
// MetricHistory 指标历史数据(简化版,供监控查询使用)
|
||||
@@ -213,29 +213,29 @@ func (MetricTag) TableName() string {
|
||||
type DashboardType string
|
||||
|
||||
const (
|
||||
DashboardTypeSystem DashboardType = "system" // 系统内置
|
||||
DashboardTypeCustom DashboardType = "custom" // 自定义
|
||||
DashboardTypeShared DashboardType = "shared" // 共享
|
||||
DashboardTypeSystem DashboardType = "system" // 系统内置
|
||||
DashboardTypeCustom DashboardType = "custom" // 自定义
|
||||
DashboardTypeShared DashboardType = "shared" // 共享
|
||||
)
|
||||
|
||||
// MonitorDashboard 监控大屏配置表
|
||||
// 定义监控大屏的元数据配置
|
||||
type MonitorDashboard struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;comment:大屏名称" json:"name"`
|
||||
Type DashboardType `gorm:"type:varchar(16);default:'custom';comment:大屏类型" json:"type"`
|
||||
Description string `gorm:"type:varchar(256);comment:描述" json:"description,omitempty"`
|
||||
Layout string `gorm:"type:text;comment:布局配置JSON" json:"layout,omitempty"`
|
||||
Theme string `gorm:"type:varchar(32);default:'dark';comment:主题: dark/light" json:"theme"`
|
||||
RefreshRate int `gorm:"default:30;comment:自动刷新间隔(秒)" json:"refresh_rate"`
|
||||
IsDefault bool `gorm:"default:false;comment:是否默认大屏" json:"is_default"`
|
||||
IsPublic bool `gorm:"default:false;comment:是否公开" json:"is_public"`
|
||||
CreatedBy uint `gorm:"index;comment:创建人ID" json:"created_by"`
|
||||
Status int `gorm:"default:1;comment:状态: 1启用 0禁用" json:"status"`
|
||||
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
||||
CreatedAt time.Time `gorm:"not null;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"`
|
||||
ID uint `gorm:"primaryKey;autoIncrement;comment:主键ID" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;comment:大屏名称" json:"name"`
|
||||
Type DashboardType `gorm:"type:varchar(16);default:'custom';comment:大屏类型" json:"type"`
|
||||
Description string `gorm:"type:varchar(256);comment:描述" json:"description,omitempty"`
|
||||
Layout string `gorm:"type:text;comment:布局配置JSON" json:"layout,omitempty"`
|
||||
Theme string `gorm:"type:varchar(32);default:'dark';comment:主题: dark/light" json:"theme"`
|
||||
RefreshRate int `gorm:"default:30;comment:自动刷新间隔(秒)" json:"refresh_rate"`
|
||||
IsDefault bool `gorm:"default:false;comment:是否默认大屏" json:"is_default"`
|
||||
IsPublic bool `gorm:"default:false;comment:是否公开" json:"is_public"`
|
||||
CreatedBy uint `gorm:"index;comment:创建人ID" json:"created_by"`
|
||||
Status int `gorm:"default:1;comment:状态: 1启用 0禁用" json:"status"`
|
||||
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
||||
CreatedAt time.Time `gorm:"not null;comment:创建时间" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null;comment:更新时间" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index;comment:删除时间" json:"deleted_at,omitempty"`
|
||||
|
||||
// 关联关系
|
||||
Panels []DashboardPanel `gorm:"foreignKey:DashboardID" json:"panels,omitempty"`
|
||||
@@ -254,16 +254,16 @@ func (MonitorDashboard) TableName() string {
|
||||
type PanelType string
|
||||
|
||||
const (
|
||||
PanelTypeChart PanelType = "chart" // 图表
|
||||
PanelTypeGauge PanelType = "gauge" // 仪表盘
|
||||
PanelTypeCounter PanelType = "counter" // 计数器
|
||||
PanelTypeTable PanelType = "table" // 表格
|
||||
PanelTypeStatus PanelType = "status" // 状态
|
||||
PanelTypeTopology PanelType = "topology" // 拓扑
|
||||
PanelTypeLog PanelType = "log" // 日志
|
||||
PanelTypeAlertList PanelType = "alert_list" // 告警列表
|
||||
PanelTypeHeatmap PanelType = "heatmap" // 热力图
|
||||
PanelTypeText PanelType = "text" // 文本
|
||||
PanelTypeChart PanelType = "chart" // 图表
|
||||
PanelTypeGauge PanelType = "gauge" // 仪表盘
|
||||
PanelTypeCounter PanelType = "counter" // 计数器
|
||||
PanelTypeTable PanelType = "table" // 表格
|
||||
PanelTypeStatus PanelType = "status" // 状态
|
||||
PanelTypeTopology PanelType = "topology" // 拓扑
|
||||
PanelTypeLog PanelType = "log" // 日志
|
||||
PanelTypeAlertList PanelType = "alert_list" // 告警列表
|
||||
PanelTypeHeatmap PanelType = "heatmap" // 热力图
|
||||
PanelTypeText PanelType = "text" // 文本
|
||||
)
|
||||
|
||||
// ChartType 图表类型
|
||||
@@ -298,13 +298,13 @@ type DashboardPanel struct {
|
||||
QueryExpr string `gorm:"type:text;comment:查询表达式" json:"query_expr,omitempty"`
|
||||
QueryConfig string `gorm:"type:text;comment:查询配置JSON" json:"query_config,omitempty"`
|
||||
// 展示配置
|
||||
TimeRange string `gorm:"type:varchar(16);default:'1h';comment:时间范围" json:"time_range"`
|
||||
RefreshRate int `gorm:"default:0;comment:刷新间隔(秒),0表示继承大屏" json:"refresh_rate"`
|
||||
Thresholds string `gorm:"type:text;comment:阈值配置JSON" json:"thresholds,omitempty"`
|
||||
Colors string `gorm:"type:text;comment:颜色配置JSON" json:"colors,omitempty"`
|
||||
Legend string `gorm:"type:varchar(64);comment:图例配置" json:"legend,omitempty"`
|
||||
Unit string `gorm:"type:varchar(32);comment:显示单位" json:"unit,omitempty"`
|
||||
Decimals int `gorm:"default:2;comment:小数位数" json:"decimals"`
|
||||
TimeRange string `gorm:"type:varchar(16);default:'1h';comment:时间范围" json:"time_range"`
|
||||
RefreshRate int `gorm:"default:0;comment:刷新间隔(秒),0表示继承大屏" json:"refresh_rate"`
|
||||
Thresholds string `gorm:"type:text;comment:阈值配置JSON" json:"thresholds,omitempty"`
|
||||
Colors string `gorm:"type:text;comment:颜色配置JSON" json:"colors,omitempty"`
|
||||
Legend string `gorm:"type:varchar(64);comment:图例配置" json:"legend,omitempty"`
|
||||
Unit string `gorm:"type:varchar(32);comment:显示单位" json:"unit,omitempty"`
|
||||
Decimals int `gorm:"default:2;comment:小数位数" json:"decimals"`
|
||||
// 状态
|
||||
Status int `gorm:"default:1;comment:状态: 1启用 0禁用" json:"status"`
|
||||
SortOrder int `gorm:"default:0;comment:排序" json:"sort_order"`
|
||||
@@ -314,18 +314,18 @@ type DashboardPanel struct {
|
||||
|
||||
// TableName 指定表名
|
||||
func (DashboardPanel) TableName() string {
|
||||
return "dashboard_panels"
|
||||
return "monitor_dashboard_panels"
|
||||
}
|
||||
|
||||
// PanelQueryConfig 面板查询配置
|
||||
type PanelQueryConfig struct {
|
||||
Metrics []string `json:"metrics"` // 指标名称列表
|
||||
Targets []uint `json:"targets"` // 目标ID列表
|
||||
Instances []string `json:"instances"` // 实例列表
|
||||
Aggregations []string `json:"aggregations"` // 聚合函数
|
||||
GroupBy []string `json:"group_by"` // 分组标签
|
||||
Filters map[string]string `json:"filters"` // 过滤条件
|
||||
Step int `json:"step"` // 步长
|
||||
Metrics []string `json:"metrics"` // 指标名称列表
|
||||
Targets []uint `json:"targets"` // 目标ID列表
|
||||
Instances []string `json:"instances"` // 实例列表
|
||||
Aggregations []string `json:"aggregations"` // 聚合函数
|
||||
GroupBy []string `json:"group_by"` // 分组标签
|
||||
Filters map[string]string `json:"filters"` // 过滤条件
|
||||
Step int `json:"step"` // 步长
|
||||
LegendFormat string `json:"legend_format"` // 图例格式
|
||||
}
|
||||
|
||||
@@ -362,9 +362,9 @@ func (HostGroup) TableName() string {
|
||||
type ProbeType string
|
||||
|
||||
const (
|
||||
ProbeTypeHTTP ProbeType = "http_get" // HTTP GET 探测
|
||||
ProbeTypeTCP ProbeType = "tcp_socket" // TCP 端口连接探测
|
||||
ProbeTypeExec ProbeType = "exec_command" // 命令执行探测
|
||||
ProbeTypeHTTP ProbeType = "http_get" // HTTP GET 探测
|
||||
ProbeTypeTCP ProbeType = "tcp_socket" // TCP 端口连接探测
|
||||
ProbeTypeExec ProbeType = "exec_command" // 命令执行探测
|
||||
)
|
||||
|
||||
// ProbeStatus 探针结果状态
|
||||
@@ -378,33 +378,33 @@ const (
|
||||
// HealthProbe 健康探针配置表
|
||||
// 存储在平台 DB,Agent 拉取配置后在目标主机本地执行,结果随心跳上报
|
||||
type HealthProbe struct {
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;index" json:"name"`
|
||||
Hostname string `gorm:"type:varchar(255);index;not null" json:"hostname"`
|
||||
ProbeType ProbeType `gorm:"type:varchar(32);not null" json:"probe_type"`
|
||||
ID uint `gorm:"primaryKey;autoIncrement" json:"id"`
|
||||
Name string `gorm:"type:varchar(128);not null;index" json:"name"`
|
||||
Hostname string `gorm:"type:varchar(255);index;not null" json:"hostname"`
|
||||
ProbeType ProbeType `gorm:"type:varchar(32);not null" json:"probe_type"`
|
||||
// HTTP 探针配置
|
||||
HTTPURL string `gorm:"type:varchar(512)" json:"http_url,omitempty"`
|
||||
HTTPMethod string `gorm:"type:varchar(10);default:GET" json:"http_method,omitempty"`
|
||||
HTTPHeaders string `gorm:"type:text" json:"http_headers,omitempty"`
|
||||
HTTPExpectCode int `gorm:"default:200" json:"http_expect_code,omitempty"`
|
||||
HTTPExpectBody string `gorm:"type:varchar(256)" json:"http_expect_body,omitempty"`
|
||||
HTTPURL string `gorm:"type:varchar(512)" json:"http_url,omitempty"`
|
||||
HTTPMethod string `gorm:"type:varchar(10);default:GET" json:"http_method,omitempty"`
|
||||
HTTPHeaders string `gorm:"type:text" json:"http_headers,omitempty"`
|
||||
HTTPExpectCode int `gorm:"default:200" json:"http_expect_code,omitempty"`
|
||||
HTTPExpectBody string `gorm:"type:varchar(256)" json:"http_expect_body,omitempty"`
|
||||
// TCP 探针配置
|
||||
TCPHost string `gorm:"type:varchar(255)" json:"tcp_host,omitempty"`
|
||||
TCPPort int `json:"tcp_port,omitempty"`
|
||||
TCPHost string `gorm:"type:varchar(255)" json:"tcp_host,omitempty"`
|
||||
TCPPort int `json:"tcp_port,omitempty"`
|
||||
// Exec 探针配置
|
||||
ExecCommand string `gorm:"type:text" json:"exec_command,omitempty"`
|
||||
ExecCommand string `gorm:"type:text" json:"exec_command,omitempty"`
|
||||
// 通用配置
|
||||
Timeout int `gorm:"default:10" json:"timeout"`
|
||||
Interval int `gorm:"default:60" json:"interval"`
|
||||
Enabled bool `gorm:"default:true;index" json:"enabled"`
|
||||
LastStatus ProbeStatus `gorm:"type:varchar(8);default:''" json:"last_status,omitempty"`
|
||||
LastCheckedAt *time.Time `json:"last_checked_at,omitempty"`
|
||||
LastLatencyMs int `json:"last_latency_ms"`
|
||||
FailCount int `json:"fail_count"`
|
||||
Description string `gorm:"type:varchar(256)" json:"description,omitempty"`
|
||||
CreatedAt time.Time `gorm:"not null" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index" json:"deleted_at,omitempty"`
|
||||
Timeout int `gorm:"default:10" json:"timeout"`
|
||||
Interval int `gorm:"default:60" json:"interval"`
|
||||
Enabled bool `gorm:"default:true;index" json:"enabled"`
|
||||
LastStatus ProbeStatus `gorm:"type:varchar(8);default:''" json:"last_status,omitempty"`
|
||||
LastCheckedAt *time.Time `json:"last_checked_at,omitempty"`
|
||||
LastLatencyMs int `json:"last_latency_ms"`
|
||||
FailCount int `json:"fail_count"`
|
||||
Description string `gorm:"type:varchar(256)" json:"description,omitempty"`
|
||||
CreatedAt time.Time `gorm:"not null" json:"created_at"`
|
||||
UpdatedAt time.Time `gorm:"not null" json:"updated_at"`
|
||||
DeletedAt *time.Time `gorm:"index" json:"deleted_at,omitempty"`
|
||||
}
|
||||
|
||||
// TableName 指定表名
|
||||
@@ -417,9 +417,8 @@ type HealthProbeResult struct {
|
||||
ProbeID uint `json:"probe_id"`
|
||||
Name string `json:"name"`
|
||||
ProbeType string `json:"probe_type"`
|
||||
Status ProbeStatus `json:"status"` // up / down
|
||||
LatencyMs int `json:"latency_ms"` // 响应延迟(ms)
|
||||
Status ProbeStatus `json:"status"` // up / down
|
||||
LatencyMs int `json:"latency_ms"` // 响应延迟(ms)
|
||||
StatusCode int `json:"status_code,omitempty"` // HTTP 状态码
|
||||
Message string `json:"message,omitempty"` // 错误/附加信息
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user