mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-26 13:30:27 +08:00
指标数据增加占比数据
This commit is contained in:
@@ -42,6 +42,8 @@ type MetricStat struct {
|
||||
NodeCluster *NodeCluster `protobuf:"bytes,30,opt,name=nodeCluster,proto3" json:"nodeCluster,omitempty"`
|
||||
Node *Node `protobuf:"bytes,31,opt,name=node,proto3" json:"node,omitempty"`
|
||||
Server *Server `protobuf:"bytes,32,opt,name=server,proto3" json:"server,omitempty"`
|
||||
SumCount int64 `protobuf:"varint,40,opt,name=sumCount,proto3" json:"sumCount,omitempty"`
|
||||
SumTotal float32 `protobuf:"fixed32,41,opt,name=sumTotal,proto3" json:"sumTotal,omitempty"`
|
||||
}
|
||||
|
||||
func (x *MetricStat) Reset() {
|
||||
@@ -153,6 +155,92 @@ func (x *MetricStat) GetServer() *Server {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *MetricStat) GetSumCount() int64 {
|
||||
if x != nil {
|
||||
return x.SumCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MetricStat) GetSumTotal() float32 {
|
||||
if x != nil {
|
||||
return x.SumTotal
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// 需要上传的统计数据
|
||||
type UploadingMetricStat struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Hash string `protobuf:"bytes,2,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||
Keys []string `protobuf:"bytes,3,rep,name=keys,proto3" json:"keys,omitempty"`
|
||||
Value float32 `protobuf:"fixed32,4,opt,name=value,proto3" json:"value,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UploadingMetricStat) Reset() {
|
||||
*x = UploadingMetricStat{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_models_model_metric_stat_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *UploadingMetricStat) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*UploadingMetricStat) ProtoMessage() {}
|
||||
|
||||
func (x *UploadingMetricStat) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_models_model_metric_stat_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use UploadingMetricStat.ProtoReflect.Descriptor instead.
|
||||
func (*UploadingMetricStat) Descriptor() ([]byte, []int) {
|
||||
return file_models_model_metric_stat_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *UploadingMetricStat) GetId() int64 {
|
||||
if x != nil {
|
||||
return x.Id
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadingMetricStat) GetHash() string {
|
||||
if x != nil {
|
||||
return x.Hash
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UploadingMetricStat) GetKeys() []string {
|
||||
if x != nil {
|
||||
return x.Keys
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *UploadingMetricStat) GetValue() float32 {
|
||||
if x != nil {
|
||||
return x.Value
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
var File_models_model_metric_stat_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_models_model_metric_stat_proto_rawDesc = []byte{
|
||||
@@ -163,7 +251,7 @@ var file_models_model_metric_stat_proto_rawDesc = []byte{
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x17, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f,
|
||||
0x64, 0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19,
|
||||
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xb1, 0x02, 0x0a, 0x0a, 0x4d, 0x65,
|
||||
0x76, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe9, 0x02, 0x0a, 0x0a, 0x4d, 0x65,
|
||||
0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01,
|
||||
0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x68, 0x61, 0x73, 0x68,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68, 0x12, 0x1a, 0x0a, 0x08,
|
||||
@@ -182,8 +270,18 @@ var file_models_model_metric_stat_proto_rawDesc = []byte{
|
||||
0x6f, 0x64, 0x65, 0x18, 0x1f, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x08, 0x2e, 0x70, 0x62, 0x2e, 0x4e,
|
||||
0x6f, 0x64, 0x65, 0x52, 0x04, 0x6e, 0x6f, 0x64, 0x65, 0x12, 0x22, 0x0a, 0x06, 0x73, 0x65, 0x72,
|
||||
0x76, 0x65, 0x72, 0x18, 0x20, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x70, 0x62, 0x2e, 0x53,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x42, 0x06, 0x5a,
|
||||
0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x72, 0x76, 0x65, 0x72, 0x52, 0x06, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x12, 0x1a, 0x0a,
|
||||
0x08, 0x73, 0x75, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x28, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x08, 0x73, 0x75, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x75, 0x6d,
|
||||
0x54, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x29, 0x20, 0x01, 0x28, 0x02, 0x52, 0x08, 0x73, 0x75, 0x6d,
|
||||
0x54, 0x6f, 0x74, 0x61, 0x6c, 0x22, 0x63, 0x0a, 0x13, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x69,
|
||||
0x6e, 0x67, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x12, 0x0e, 0x0a, 0x02,
|
||||
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04,
|
||||
0x68, 0x61, 0x73, 0x68, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x68, 0x61, 0x73, 0x68,
|
||||
0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04,
|
||||
0x6b, 0x65, 0x79, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -198,17 +296,18 @@ func file_models_model_metric_stat_proto_rawDescGZIP() []byte {
|
||||
return file_models_model_metric_stat_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_models_model_metric_stat_proto_msgTypes = make([]protoimpl.MessageInfo, 1)
|
||||
var file_models_model_metric_stat_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
|
||||
var file_models_model_metric_stat_proto_goTypes = []interface{}{
|
||||
(*MetricStat)(nil), // 0: pb.MetricStat
|
||||
(*NodeCluster)(nil), // 1: pb.NodeCluster
|
||||
(*Node)(nil), // 2: pb.Node
|
||||
(*Server)(nil), // 3: pb.Server
|
||||
(*UploadingMetricStat)(nil), // 1: pb.UploadingMetricStat
|
||||
(*NodeCluster)(nil), // 2: pb.NodeCluster
|
||||
(*Node)(nil), // 3: pb.Node
|
||||
(*Server)(nil), // 4: pb.Server
|
||||
}
|
||||
var file_models_model_metric_stat_proto_depIdxs = []int32{
|
||||
1, // 0: pb.MetricStat.nodeCluster:type_name -> pb.NodeCluster
|
||||
2, // 1: pb.MetricStat.node:type_name -> pb.Node
|
||||
3, // 2: pb.MetricStat.server:type_name -> pb.Server
|
||||
2, // 0: pb.MetricStat.nodeCluster:type_name -> pb.NodeCluster
|
||||
3, // 1: pb.MetricStat.node:type_name -> pb.Node
|
||||
4, // 2: pb.MetricStat.server:type_name -> pb.Server
|
||||
3, // [3:3] is the sub-list for method output_type
|
||||
3, // [3:3] is the sub-list for method input_type
|
||||
3, // [3:3] is the sub-list for extension type_name
|
||||
@@ -237,6 +336,18 @@ func file_models_model_metric_stat_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_models_model_metric_stat_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*UploadingMetricStat); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@@ -244,7 +355,7 @@ func file_models_model_metric_stat_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_models_model_metric_stat_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 1,
|
||||
NumMessages: 2,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@@ -35,7 +35,13 @@ type UploadMetricStatsRequest struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
MetricStats []*MetricStat `protobuf:"bytes,1,rep,name=metricStats,proto3" json:"metricStats,omitempty"`
|
||||
ServerId int64 `protobuf:"varint,1,opt,name=serverId,proto3" json:"serverId,omitempty"`
|
||||
Time string `protobuf:"bytes,2,opt,name=time,proto3" json:"time,omitempty"`
|
||||
Count int64 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
|
||||
Total float32 `protobuf:"fixed32,4,opt,name=total,proto3" json:"total,omitempty"`
|
||||
Version int32 `protobuf:"varint,5,opt,name=version,proto3" json:"version,omitempty"`
|
||||
ItemId int64 `protobuf:"varint,6,opt,name=itemId,proto3" json:"itemId,omitempty"`
|
||||
MetricStats []*UploadingMetricStat `protobuf:"bytes,7,rep,name=metricStats,proto3" json:"metricStats,omitempty"`
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) Reset() {
|
||||
@@ -70,7 +76,49 @@ func (*UploadMetricStatsRequest) Descriptor() ([]byte, []int) {
|
||||
return file_service_metric_stat_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetMetricStats() []*MetricStat {
|
||||
func (x *UploadMetricStatsRequest) GetServerId() int64 {
|
||||
if x != nil {
|
||||
return x.ServerId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetTime() string {
|
||||
if x != nil {
|
||||
return x.Time
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetCount() int64 {
|
||||
if x != nil {
|
||||
return x.Count
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetTotal() float32 {
|
||||
if x != nil {
|
||||
return x.Total
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetVersion() int32 {
|
||||
if x != nil {
|
||||
return x.Version
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetItemId() int64 {
|
||||
if x != nil {
|
||||
return x.ItemId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UploadMetricStatsRequest) GetMetricStats() []*UploadingMetricStat {
|
||||
if x != nil {
|
||||
return x.MetricStats
|
||||
}
|
||||
@@ -244,43 +292,53 @@ var file_service_metric_stat_proto_rawDesc = []byte{
|
||||
0x1e, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x5f, 0x6d, 0x65,
|
||||
0x74, 0x72, 0x69, 0x63, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a,
|
||||
0x19, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x73, 0x73,
|
||||
0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x4c, 0x0a, 0x18, 0x55, 0x70,
|
||||
0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x30, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63,
|
||||
0x53, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62,
|
||||
0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x52, 0x0b, 0x6d, 0x65, 0x74,
|
||||
0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x22, 0x3d, 0x0a, 0x17, 0x43, 0x6f, 0x75, 0x6e,
|
||||
0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75,
|
||||
0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65,
|
||||
0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69,
|
||||
0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x22, 0x68, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x4d,
|
||||
0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49,
|
||||
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49,
|
||||
0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a,
|
||||
0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a,
|
||||
0x65, 0x22, 0x4b, 0x0a, 0x17, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53,
|
||||
0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b,
|
||||
0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28,
|
||||
0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61,
|
||||
0x74, 0x52, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x32, 0xe9,
|
||||
0x01, 0x0a, 0x11, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x53, 0x65, 0x72,
|
||||
0x76, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, 0x11, 0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x65,
|
||||
0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x55,
|
||||
0x61, 0x67, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xe3, 0x01, 0x0a, 0x18, 0x55,
|
||||
0x70, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43,
|
||||
0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x45, 0x0a, 0x10, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x70, 0x62,
|
||||
0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74,
|
||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50,
|
||||
0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a,
|
||||
0x0a, 0x0f, 0x6c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74,
|
||||
0x73, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69,
|
||||
0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e,
|
||||
0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61,
|
||||
0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
|
||||
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65,
|
||||
0x72, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x14, 0x0a,
|
||||
0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x02, 0x52, 0x05, 0x74, 0x6f,
|
||||
0x74, 0x61, 0x6c, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x05,
|
||||
0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x69, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x69,
|
||||
0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x39, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53,
|
||||
0x74, 0x61, 0x74, 0x73, 0x18, 0x07, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x17, 0x2e, 0x70, 0x62, 0x2e,
|
||||
0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x69, 0x6e, 0x67, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53,
|
||||
0x74, 0x61, 0x74, 0x52, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73,
|
||||
0x22, 0x3d, 0x0a, 0x17, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53,
|
||||
0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x6d,
|
||||
0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x03, 0x52, 0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x22,
|
||||
0x68, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61,
|
||||
0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x74,
|
||||
0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x16, 0x0a,
|
||||
0x06, 0x6f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x6f,
|
||||
0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x03, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x22, 0x4b, 0x0a, 0x17, 0x4c, 0x69, 0x73,
|
||||
0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70,
|
||||
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74,
|
||||
0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x4d,
|
||||
0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x52, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69,
|
||||
0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x32, 0xe9, 0x01, 0x0a, 0x11, 0x4d, 0x65, 0x74, 0x72, 0x69,
|
||||
0x63, 0x53, 0x74, 0x61, 0x74, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x41, 0x0a, 0x11,
|
||||
0x75, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74,
|
||||
0x73, 0x12, 0x1c, 0x2e, 0x70, 0x62, 0x2e, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x4d, 0x65, 0x74,
|
||||
0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
|
||||
0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12,
|
||||
0x45, 0x0a, 0x10, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74,
|
||||
0x61, 0x74, 0x73, 0x12, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x4d, 0x65,
|
||||
0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
|
||||
0x1a, 0x14, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65,
|
||||
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4a, 0x0a, 0x0f, 0x6c, 0x69, 0x73, 0x74, 0x4d, 0x65,
|
||||
0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x12, 0x1a, 0x2e, 0x70, 0x62, 0x2e, 0x4c,
|
||||
0x69, 0x73, 0x74, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65,
|
||||
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x62, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x4d,
|
||||
0x65, 0x74, 0x72, 0x69, 0x63, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
|
||||
0x73, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -301,18 +359,19 @@ var file_service_metric_stat_proto_goTypes = []interface{}{
|
||||
(*CountMetricStatsRequest)(nil), // 1: pb.CountMetricStatsRequest
|
||||
(*ListMetricStatsRequest)(nil), // 2: pb.ListMetricStatsRequest
|
||||
(*ListMetricStatsResponse)(nil), // 3: pb.ListMetricStatsResponse
|
||||
(*MetricStat)(nil), // 4: pb.MetricStat
|
||||
(*RPCSuccess)(nil), // 5: pb.RPCSuccess
|
||||
(*RPCCountResponse)(nil), // 6: pb.RPCCountResponse
|
||||
(*UploadingMetricStat)(nil), // 4: pb.UploadingMetricStat
|
||||
(*MetricStat)(nil), // 5: pb.MetricStat
|
||||
(*RPCSuccess)(nil), // 6: pb.RPCSuccess
|
||||
(*RPCCountResponse)(nil), // 7: pb.RPCCountResponse
|
||||
}
|
||||
var file_service_metric_stat_proto_depIdxs = []int32{
|
||||
4, // 0: pb.UploadMetricStatsRequest.metricStats:type_name -> pb.MetricStat
|
||||
4, // 1: pb.ListMetricStatsResponse.metricStats:type_name -> pb.MetricStat
|
||||
4, // 0: pb.UploadMetricStatsRequest.metricStats:type_name -> pb.UploadingMetricStat
|
||||
5, // 1: pb.ListMetricStatsResponse.metricStats:type_name -> pb.MetricStat
|
||||
0, // 2: pb.MetricStatService.uploadMetricStats:input_type -> pb.UploadMetricStatsRequest
|
||||
1, // 3: pb.MetricStatService.countMetricStats:input_type -> pb.CountMetricStatsRequest
|
||||
2, // 4: pb.MetricStatService.listMetricStats:input_type -> pb.ListMetricStatsRequest
|
||||
5, // 5: pb.MetricStatService.uploadMetricStats:output_type -> pb.RPCSuccess
|
||||
6, // 6: pb.MetricStatService.countMetricStats:output_type -> pb.RPCCountResponse
|
||||
6, // 5: pb.MetricStatService.uploadMetricStats:output_type -> pb.RPCSuccess
|
||||
7, // 6: pb.MetricStatService.countMetricStats:output_type -> pb.RPCCountResponse
|
||||
3, // 7: pb.MetricStatService.listMetricStats:output_type -> pb.ListMetricStatsResponse
|
||||
5, // [5:8] is the sub-list for method output_type
|
||||
2, // [2:5] is the sub-list for method input_type
|
||||
|
||||
@@ -21,4 +21,15 @@ message MetricStat {
|
||||
NodeCluster nodeCluster = 30;
|
||||
Node node = 31;
|
||||
Server server = 32;
|
||||
|
||||
int64 sumCount = 40;
|
||||
float sumTotal = 41;
|
||||
}
|
||||
|
||||
// 需要上传的统计数据
|
||||
message UploadingMetricStat {
|
||||
int64 id = 1;
|
||||
string hash = 2;
|
||||
repeated string keys = 3;
|
||||
float value = 4;
|
||||
}
|
||||
@@ -19,7 +19,13 @@ service MetricStatService {
|
||||
|
||||
// 上传统计数据
|
||||
message UploadMetricStatsRequest {
|
||||
repeated MetricStat metricStats = 1;
|
||||
int64 serverId = 1;
|
||||
string time = 2;
|
||||
int64 count = 3;
|
||||
float total = 4;
|
||||
int32 version = 5;
|
||||
int64 itemId = 6;
|
||||
repeated UploadingMetricStat metricStats = 7;
|
||||
}
|
||||
|
||||
// 计算指标数据数量
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package serverconfigs
|
||||
|
||||
import (
|
||||
"github.com/iwind/TeaGo/Tea"
|
||||
timeutil "github.com/iwind/TeaGo/utils/time"
|
||||
"time"
|
||||
)
|
||||
@@ -16,7 +17,7 @@ type MetricItemConfig struct {
|
||||
PeriodUnit MetricItemPeriodUnit `yaml:"periodUnit" json:"periodUnit"`
|
||||
Keys []string `yaml:"keys" json:"keys"`
|
||||
Value string `yaml:"value" json:"value"`
|
||||
Version int `yaml:"version" json:"version"`
|
||||
Version int32 `yaml:"version" json:"version"`
|
||||
|
||||
sumType string // 统计类型
|
||||
baseTime time.Time // 基准时间
|
||||
@@ -117,8 +118,8 @@ func (this *MetricItemConfig) CurrentTime() string {
|
||||
return t
|
||||
}
|
||||
|
||||
// ExpiresTime 根据周期计算过期时间
|
||||
func (this *MetricItemConfig) ExpiresTime() string {
|
||||
// ServerExpiresTime 根据周期计算服务器端数据过期时间
|
||||
func (this *MetricItemConfig) ServerExpiresTime() string {
|
||||
switch this.PeriodUnit {
|
||||
case MetricItemPeriodUnitMonth:
|
||||
return timeutil.Format("Ym", time.Now().AddDate(0, -(this.Period*4), 0))
|
||||
@@ -135,8 +136,29 @@ func (this *MetricItemConfig) ExpiresTime() string {
|
||||
}
|
||||
}
|
||||
|
||||
// LocalExpiresTime 根据周期计算本地端过期时间
|
||||
func (this *MetricItemConfig) LocalExpiresTime() string {
|
||||
switch this.PeriodUnit {
|
||||
case MetricItemPeriodUnitMonth:
|
||||
return timeutil.Format("Ym", time.Now().AddDate(0, -(this.Period+1), 0))
|
||||
case MetricItemPeriodUnitWeek:
|
||||
return timeutil.FormatTime("YW", time.Now().Unix()-86400*7*int64(this.Period+1))
|
||||
case MetricItemPeriodUnitDay:
|
||||
return timeutil.FormatTime("Ymd", time.Now().Unix()-86400*int64(this.Period+1))
|
||||
case MetricItemPeriodUnitHour:
|
||||
return timeutil.FormatTime("YmdH", time.Now().Unix()-3600*int64(this.Period+1))
|
||||
case MetricItemPeriodUnitMinute:
|
||||
return timeutil.FormatTime("YmdHi", time.Now().Unix()-60*int64(this.Period+60))
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
// UploadDuration 上传数据的周期
|
||||
func (this *MetricItemConfig) UploadDuration() time.Duration {
|
||||
if Tea.IsTesting() {
|
||||
return 5 * time.Second
|
||||
}
|
||||
switch this.PeriodUnit {
|
||||
case MetricItemPeriodUnitMonth:
|
||||
return 10 * time.Minute
|
||||
|
||||
Reference in New Issue
Block a user