mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-07 23:30:25 +08:00
实现服务看板(企业版)
This commit is contained in:
@@ -25,6 +25,9 @@ type NodeStatus struct {
|
||||
Load15m float64 `json:"load15m"`
|
||||
ConnectionCount int `json:"connectionCount"` // 连接数
|
||||
|
||||
TrafficInBytes uint64 `json:"trafficInBytes"`
|
||||
TrafficOutBytes uint64 `json:"trafficOutBytes"`
|
||||
|
||||
CacheTotalDiskSize int64 `json:"cacheTotalDiskSize"`
|
||||
CacheTotalMemorySize int64 `json:"cacheTotalMemorySize"`
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ const (
|
||||
NodeValueItemTrafficIn NodeValueItem = "trafficIn" // 上行流量
|
||||
NodeValueItemTrafficOut NodeValueItem = "trafficOut" // 下行流量
|
||||
NodeValueItemConnections NodeValueItem = "connections" // 连接数
|
||||
NodeValueItemRequests NodeValueItem = "requests" // 请求访问量
|
||||
NodeValueItemAttackRequests NodeValueItem = "attackRequests" // 攻击请求访问量
|
||||
NodeValueItemDisk NodeValueItem = "disk" // 磁盘
|
||||
)
|
||||
|
||||
@@ -109,6 +111,28 @@ var nodeValueItemDefinitions = []*nodeValueItemDefinition{
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Code: NodeValueItemRequests,
|
||||
Name: "请求数",
|
||||
Params: []*nodeValueItemParamDefinition{
|
||||
{
|
||||
Code: "total",
|
||||
Name: "总数",
|
||||
Description: "请求总数",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Code: NodeValueItemAttackRequests,
|
||||
Name: "攻击请求数",
|
||||
Params: []*nodeValueItemParamDefinition{
|
||||
{
|
||||
Code: "total",
|
||||
Name: "总数",
|
||||
Description: "攻击请求总数",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Code: NodeValueItemDisk,
|
||||
Name: "硬盘空间",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -161,6 +161,15 @@ message ListEnabledNodesMatchRequest {
|
||||
string keyword = 6;
|
||||
int64 nodeGroupId = 7;
|
||||
int64 nodeRegionId = 8;
|
||||
|
||||
bool cpuAsc = 20;
|
||||
bool cpuDesc = 21;
|
||||
bool memoryAsc = 22;
|
||||
bool memoryDesc = 23;
|
||||
bool trafficInAsc = 24;
|
||||
bool trafficInDesc = 25;
|
||||
bool trafficOutAsc = 26;
|
||||
bool trafficOutDesc = 27;
|
||||
}
|
||||
|
||||
message ListEnabledNodesMatchResponse {
|
||||
|
||||
@@ -5,6 +5,8 @@ package pb;
|
||||
|
||||
import "models/model_server_stat_board.proto";
|
||||
import "models/model_message_node_value.proto";
|
||||
import "models/model_metric_chart.proto";
|
||||
import "models/model_metric_stat.proto";
|
||||
|
||||
// 统计看板
|
||||
service ServerStatBoardService {
|
||||
@@ -13,6 +15,12 @@ service ServerStatBoardService {
|
||||
|
||||
// 组合集群看板数据
|
||||
rpc composeServerStatNodeClusterBoard (ComposeServerStatNodeClusterBoardRequest) returns (ComposeServerStatNodeClusterBoardResponse);
|
||||
|
||||
// 组合节点看板数据
|
||||
rpc composeServerStatNodeBoard (ComposeServerStatNodeBoardRequest) returns (ComposeServerStatNodeBoardResponse);
|
||||
|
||||
// 组合服务看板数据
|
||||
rpc composeServerStatBoard (ComposeServerStatBoardRequest) returns (ComposeServerStatBoardResponse);
|
||||
}
|
||||
|
||||
// 读取所有看板
|
||||
@@ -44,6 +52,8 @@ message ComposeServerStatNodeClusterBoardResponse {
|
||||
repeated NodeValue memoryNodeValues = 35;
|
||||
repeated NodeValue loadNodeValues = 36;
|
||||
|
||||
repeated MetricData metricCharts = 37;
|
||||
|
||||
message DailyTrafficStat {
|
||||
string day = 1;
|
||||
int64 bytes = 2;
|
||||
@@ -67,6 +77,72 @@ message ComposeServerStatNodeClusterBoardResponse {
|
||||
int64 bytes = 4;
|
||||
}
|
||||
|
||||
message DomainStat {
|
||||
int64 serverId = 1;
|
||||
string domain = 2;
|
||||
int64 countRequests = 3;
|
||||
int64 bytes = 4;
|
||||
}
|
||||
|
||||
message MetricData {
|
||||
MetricChart metricChart = 1;
|
||||
repeated MetricStat metricStats = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// 组合节点看板数据
|
||||
message ComposeServerStatNodeBoardRequest {
|
||||
int64 nodeId = 1;
|
||||
}
|
||||
|
||||
message ComposeServerStatNodeBoardResponse {
|
||||
bool isActive = 1;
|
||||
int64 trafficInBytes = 2;
|
||||
int64 trafficOutBytes = 3;
|
||||
int64 countRequests = 4;
|
||||
int64 countAttackRequests = 5;
|
||||
int64 countConnections = 6;
|
||||
int64 cacheDiskSize = 7;
|
||||
int64 cacheMemorySize = 8;
|
||||
float cpuUsage = 9;
|
||||
float memoryUsage = 10;
|
||||
int64 memoryTotalSize = 11;
|
||||
float load = 12;
|
||||
|
||||
repeated CacheDisk cacheDisks = 30;
|
||||
repeated DailyTrafficStat dailyTrafficStats = 31;
|
||||
repeated HourlyTrafficStat hourlyTrafficStats = 32;
|
||||
repeated DomainStat topDomainStats = 33;
|
||||
|
||||
repeated NodeValue cpuNodeValues = 34;
|
||||
repeated NodeValue memoryNodeValues = 35;
|
||||
repeated NodeValue loadNodeValues = 36;
|
||||
|
||||
repeated MetricData metricCharts = 37;
|
||||
|
||||
message CacheDisk {
|
||||
string path = 1;
|
||||
string mount = 2;
|
||||
int64 totalSize = 3;
|
||||
int64 usedSize = 4;
|
||||
float usage = 5;
|
||||
}
|
||||
|
||||
message DailyTrafficStat {
|
||||
string day = 1;
|
||||
int64 bytes = 2;
|
||||
int64 cachedBytes = 3;
|
||||
int64 countRequests = 4;
|
||||
int64 countCachedRequests = 5;
|
||||
}
|
||||
|
||||
message HourlyTrafficStat {
|
||||
string hour = 1;
|
||||
int64 bytes = 2;
|
||||
int64 cachedBytes = 3;
|
||||
int64 countRequests = 4;
|
||||
int64 countCachedRequests = 5;
|
||||
}
|
||||
|
||||
message DomainStat {
|
||||
int64 serverId = 1;
|
||||
@@ -74,4 +150,58 @@ message ComposeServerStatNodeClusterBoardResponse {
|
||||
int64 countRequests = 3;
|
||||
int64 bytes = 4;
|
||||
}
|
||||
|
||||
message MetricData {
|
||||
MetricChart metricChart = 1;
|
||||
repeated MetricStat metricStats = 2;
|
||||
}
|
||||
}
|
||||
|
||||
// 组合服务看板数据
|
||||
message ComposeServerStatBoardRequest {
|
||||
int64 serverId = 1;
|
||||
}
|
||||
|
||||
message ComposeServerStatBoardResponse {
|
||||
repeated DailyTrafficStat dailyTrafficStats = 30;
|
||||
repeated HourlyTrafficStat hourlyTrafficStats = 31;
|
||||
repeated NodeStat topNodeStats = 32;
|
||||
repeated DomainStat topDomainStats = 33;
|
||||
|
||||
repeated MetricData metricCharts = 34;
|
||||
|
||||
message DailyTrafficStat {
|
||||
string day = 1;
|
||||
int64 bytes = 2;
|
||||
int64 cachedBytes = 3;
|
||||
int64 countRequests = 4;
|
||||
int64 countCachedRequests = 5;
|
||||
}
|
||||
|
||||
message HourlyTrafficStat {
|
||||
string hour = 1;
|
||||
int64 bytes = 2;
|
||||
int64 cachedBytes = 3;
|
||||
int64 countRequests = 4;
|
||||
int64 countCachedRequests = 5;
|
||||
}
|
||||
|
||||
message NodeStat {
|
||||
int64 nodeId = 1;
|
||||
string nodeName = 2;
|
||||
int64 countRequests = 3;
|
||||
int64 bytes = 4;
|
||||
}
|
||||
|
||||
message DomainStat {
|
||||
int64 serverId = 1;
|
||||
string domain = 2;
|
||||
int64 countRequests = 3;
|
||||
int64 bytes = 4;
|
||||
}
|
||||
|
||||
message MetricData {
|
||||
MetricChart metricChart = 1;
|
||||
repeated MetricStat metricStats = 2;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,14 @@ const (
|
||||
MetricItemPeriodUnitMonth MetricItemPeriodUnit = "month"
|
||||
)
|
||||
|
||||
// MetricItemValueType 值类型
|
||||
type MetricItemValueType = string
|
||||
|
||||
const (
|
||||
MetricItemValueTypeCount MetricItemValueType = "count" // 数量
|
||||
MetricItemValueTypeByte MetricItemValueType = "byte" // 字节
|
||||
)
|
||||
|
||||
// FindAllMetricKeyDefinitions 指标对象定义
|
||||
func FindAllMetricKeyDefinitions(category MetricItemCategory) []*shared.Definition {
|
||||
switch category {
|
||||
@@ -92,6 +100,10 @@ func FindAllMetricKeyDefinitions(category MetricItemCategory) []*shared.Definiti
|
||||
},
|
||||
|
||||
// ========= 以下是响应 =========
|
||||
{
|
||||
Name: "状态码",
|
||||
Code: "${status}",
|
||||
},
|
||||
{
|
||||
Name: "响应的Content-Type值",
|
||||
Code: "${response.contentType}",
|
||||
@@ -107,60 +119,79 @@ func FindAllMetricKeyDefinitions(category MetricItemCategory) []*shared.Definiti
|
||||
return []*shared.Definition{}
|
||||
}
|
||||
|
||||
// MetricValueDefinition 指标数值定义
|
||||
type MetricValueDefinition struct {
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description"`
|
||||
Icon string `json:"icon"`
|
||||
Type string `json:"type"`
|
||||
}
|
||||
|
||||
// FindAllMetricValueDefinitions 指标数值定义
|
||||
func FindAllMetricValueDefinitions(category MetricItemCategory) []*shared.Definition {
|
||||
func FindAllMetricValueDefinitions(category MetricItemCategory) []*MetricValueDefinition {
|
||||
switch category {
|
||||
case MetricItemCategoryHTTP:
|
||||
return []*shared.Definition{
|
||||
return []*MetricValueDefinition{
|
||||
{
|
||||
Name: "请求数",
|
||||
Code: "${countRequest}",
|
||||
Type: MetricItemValueTypeCount,
|
||||
},
|
||||
{
|
||||
Name: "连接数",
|
||||
Code: "${countConnection}",
|
||||
Type: MetricItemValueTypeCount,
|
||||
},
|
||||
{
|
||||
Name: "下行流量",
|
||||
Code: "${countTrafficOut}",
|
||||
Type: MetricItemValueTypeByte,
|
||||
},
|
||||
{
|
||||
Name: "上行流量",
|
||||
Code: "${countTrafficIn}",
|
||||
Type: MetricItemValueTypeByte,
|
||||
},
|
||||
}
|
||||
case MetricItemCategoryTCP:
|
||||
return []*shared.Definition{
|
||||
return []*MetricValueDefinition{
|
||||
{
|
||||
Name: "连接数",
|
||||
Code: "${countConnection}",
|
||||
Type: MetricItemValueTypeCount,
|
||||
},
|
||||
{
|
||||
Name: "下行流量",
|
||||
Code: "${countTrafficOut}",
|
||||
Type: MetricItemValueTypeByte,
|
||||
},
|
||||
{
|
||||
Name: "上行流量",
|
||||
Code: "${countTrafficIn}",
|
||||
Type: MetricItemValueTypeByte,
|
||||
},
|
||||
}
|
||||
case MetricItemCategoryUDP:
|
||||
return []*shared.Definition{
|
||||
return []*MetricValueDefinition{
|
||||
{
|
||||
Name: "连接数",
|
||||
Code: "${countConnection}",
|
||||
Type: MetricItemValueTypeCount,
|
||||
},
|
||||
{
|
||||
Name: "下行流量",
|
||||
Code: "${countTrafficOut}",
|
||||
Type: MetricItemValueTypeByte,
|
||||
},
|
||||
{
|
||||
Name: "上行流量",
|
||||
Code: "${countTrafficIn}",
|
||||
Type: MetricItemValueTypeByte,
|
||||
},
|
||||
}
|
||||
}
|
||||
return []*shared.Definition{}
|
||||
return []*MetricValueDefinition{}
|
||||
}
|
||||
|
||||
func FindMetricValueName(category MetricItemCategory, code string) string {
|
||||
@@ -172,6 +203,15 @@ func FindMetricValueName(category MetricItemCategory, code string) string {
|
||||
return code
|
||||
}
|
||||
|
||||
func FindMetricValueType(category MetricItemCategory, code string) string {
|
||||
for _, def := range FindAllMetricValueDefinitions(category) {
|
||||
if def.Code == code {
|
||||
return def.Type
|
||||
}
|
||||
}
|
||||
return MetricItemValueTypeCount
|
||||
}
|
||||
|
||||
// HumanMetricTime 格式化时间,让时间更易读
|
||||
func HumanMetricTime(periodUnit MetricItemPeriodUnit, time string) string {
|
||||
switch periodUnit {
|
||||
|
||||
Reference in New Issue
Block a user