实现基础的统计指标

This commit is contained in:
刘祥超
2021-06-30 20:50:17 +08:00
parent e4b59c5e85
commit 32cb66db4c
14 changed files with 1481 additions and 110 deletions

5
go.mod
View File

@@ -6,7 +6,10 @@ require (
github.com/cespare/xxhash/v2 v2.1.1
github.com/go-yaml/yaml v2.1.0+incompatible
github.com/golang/protobuf v1.4.2
github.com/iwind/TeaGo v0.0.0-20210411134150-ddf57e240c2f
github.com/iwind/TeaGo v0.0.0-20210628135026-38575a4ab060
github.com/json-iterator/go v1.1.11 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
google.golang.org/grpc v1.32.0
google.golang.org/protobuf v1.25.0
gopkg.in/yaml.v2 v2.4.0 // indirect

8
go.sum
View File

@@ -46,13 +46,21 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iwind/TeaGo v0.0.0-20210411134150-ddf57e240c2f h1:r2O8PONj/KiuZjJHVHn7KlCePUIjNtgAmvLfgRafQ8o=
github.com/iwind/TeaGo v0.0.0-20210411134150-ddf57e240c2f/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
github.com/iwind/TeaGo v0.0.0-20210628135026-38575a4ab060 h1:qdLtK4PDXxk2vMKkTWl5Fl9xqYuRCukzWAgJbLHdfOo=
github.com/iwind/TeaGo v0.0.0-20210628135026-38575a4ab060/go.mod h1:KU4mS7QNiZ7QWEuDBk1zw0/Q2LrAPZv3tycEFBsuUwc=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=

View File

@@ -42,7 +42,11 @@ type NodeConfig struct {
paddedId string
// firewall
firewallPolicies []*firewallconfigs.HTTPFirewallPolicy
// metrics
hasHTTPConnectionMetrics bool
}
// SharedNodeConfig 取得当前节点配置单例
@@ -144,11 +148,15 @@ func (this *NodeConfig) Init() error {
}
// metric items
this.hasHTTPConnectionMetrics = false
for _, item := range this.MetricItems {
err := item.Init()
if err != nil {
return err
}
if item.IsOn && item.HasHTTPConnectionValue() {
this.hasHTTPConnectionMetrics = true
}
}
return nil
@@ -202,6 +210,11 @@ func (this *NodeConfig) PaddedId() string {
return this.paddedId
}
// HasHTTPConnectionMetrics 是否含有HTTP连接数的指标
func (this *NodeConfig) HasHTTPConnectionMetrics() bool {
return this.hasHTTPConnectionMetrics
}
// 搜索WAF策略
func (this *NodeConfig) lookupWeb(web *serverconfigs.HTTPWebConfig) {
if web == nil || !web.IsOn {

View File

@@ -0,0 +1,259 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: models/model_metric_stat.proto
package pb
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// 统计数据
type MetricStat 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"`
ServerId int64 `protobuf:"varint,3,opt,name=serverId,proto3" json:"serverId,omitempty"`
ItemId int64 `protobuf:"varint,4,opt,name=itemId,proto3" json:"itemId,omitempty"`
Keys []string `protobuf:"bytes,5,rep,name=keys,proto3" json:"keys,omitempty"`
Value float32 `protobuf:"fixed32,6,opt,name=value,proto3" json:"value,omitempty"`
Time string `protobuf:"bytes,7,opt,name=time,proto3" json:"time,omitempty"`
Version int32 `protobuf:"varint,8,opt,name=version,proto3" json:"version,omitempty"`
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"`
}
func (x *MetricStat) Reset() {
*x = MetricStat{}
if protoimpl.UnsafeEnabled {
mi := &file_models_model_metric_stat_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *MetricStat) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*MetricStat) ProtoMessage() {}
func (x *MetricStat) ProtoReflect() protoreflect.Message {
mi := &file_models_model_metric_stat_proto_msgTypes[0]
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 MetricStat.ProtoReflect.Descriptor instead.
func (*MetricStat) Descriptor() ([]byte, []int) {
return file_models_model_metric_stat_proto_rawDescGZIP(), []int{0}
}
func (x *MetricStat) GetId() int64 {
if x != nil {
return x.Id
}
return 0
}
func (x *MetricStat) GetHash() string {
if x != nil {
return x.Hash
}
return ""
}
func (x *MetricStat) GetServerId() int64 {
if x != nil {
return x.ServerId
}
return 0
}
func (x *MetricStat) GetItemId() int64 {
if x != nil {
return x.ItemId
}
return 0
}
func (x *MetricStat) GetKeys() []string {
if x != nil {
return x.Keys
}
return nil
}
func (x *MetricStat) GetValue() float32 {
if x != nil {
return x.Value
}
return 0
}
func (x *MetricStat) GetTime() string {
if x != nil {
return x.Time
}
return ""
}
func (x *MetricStat) GetVersion() int32 {
if x != nil {
return x.Version
}
return 0
}
func (x *MetricStat) GetNodeCluster() *NodeCluster {
if x != nil {
return x.NodeCluster
}
return nil
}
func (x *MetricStat) GetNode() *Node {
if x != nil {
return x.Node
}
return nil
}
func (x *MetricStat) GetServer() *Server {
if x != nil {
return x.Server
}
return nil
}
var File_models_model_metric_stat_proto protoreflect.FileDescriptor
var file_models_model_metric_stat_proto_rawDesc = []byte{
0x0a, 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,
0x12, 0x02, 0x70, 0x62, 0x1a, 0x1f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x73, 0x2f, 0x6d, 0x6f, 0x64,
0x65, 0x6c, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x5f, 0x63, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x2e,
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,
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,
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08,
0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x69, 0x74, 0x65, 0x6d,
0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x06, 0x69, 0x74, 0x65, 0x6d, 0x49, 0x64,
0x12, 0x12, 0x0a, 0x04, 0x6b, 0x65, 0x79, 0x73, 0x18, 0x05, 0x20, 0x03, 0x28, 0x09, 0x52, 0x04,
0x6b, 0x65, 0x79, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x06, 0x20,
0x01, 0x28, 0x02, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x69,
0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x18,
0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52,
0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x31, 0x0a, 0x0b, 0x6e, 0x6f, 0x64, 0x65,
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x18, 0x1e, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
0x70, 0x62, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x52, 0x0b,
0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x12, 0x1c, 0x0a, 0x04, 0x6e,
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,
}
var (
file_models_model_metric_stat_proto_rawDescOnce sync.Once
file_models_model_metric_stat_proto_rawDescData = file_models_model_metric_stat_proto_rawDesc
)
func file_models_model_metric_stat_proto_rawDescGZIP() []byte {
file_models_model_metric_stat_proto_rawDescOnce.Do(func() {
file_models_model_metric_stat_proto_rawDescData = protoimpl.X.CompressGZIP(file_models_model_metric_stat_proto_rawDescData)
})
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_goTypes = []interface{}{
(*MetricStat)(nil), // 0: pb.MetricStat
(*NodeCluster)(nil), // 1: pb.NodeCluster
(*Node)(nil), // 2: pb.Node
(*Server)(nil), // 3: 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
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
3, // [3:3] is the sub-list for extension extendee
0, // [0:3] is the sub-list for field type_name
}
func init() { file_models_model_metric_stat_proto_init() }
func file_models_model_metric_stat_proto_init() {
if File_models_model_metric_stat_proto != nil {
return
}
file_models_model_node_cluster_proto_init()
file_models_model_node_proto_init()
file_models_model_server_proto_init()
if !protoimpl.UnsafeEnabled {
file_models_model_metric_stat_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*MetricStat); 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{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_models_model_metric_stat_proto_rawDesc,
NumEnums: 0,
NumMessages: 1,
NumExtensions: 0,
NumServices: 0,
},
GoTypes: file_models_model_metric_stat_proto_goTypes,
DependencyIndexes: file_models_model_metric_stat_proto_depIdxs,
MessageInfos: file_models_model_metric_stat_proto_msgTypes,
}.Build()
File_models_model_metric_stat_proto = out.File
file_models_model_metric_stat_proto_rawDesc = nil
file_models_model_metric_stat_proto_goTypes = nil
file_models_model_metric_stat_proto_depIdxs = nil
}

View File

@@ -112,6 +112,54 @@ func (x *RPCCountResponse) GetCount() int64 {
return 0
}
// 是否存在
type RPCExists struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Exists bool `protobuf:"varint,1,opt,name=exists,proto3" json:"exists,omitempty"`
}
func (x *RPCExists) Reset() {
*x = RPCExists{}
if protoimpl.UnsafeEnabled {
mi := &file_models_rpc_messages_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *RPCExists) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*RPCExists) ProtoMessage() {}
func (x *RPCExists) ProtoReflect() protoreflect.Message {
mi := &file_models_rpc_messages_proto_msgTypes[2]
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 RPCExists.ProtoReflect.Descriptor instead.
func (*RPCExists) Descriptor() ([]byte, []int) {
return file_models_rpc_messages_proto_rawDescGZIP(), []int{2}
}
func (x *RPCExists) GetExists() bool {
if x != nil {
return x.Exists
}
return false
}
var File_models_rpc_messages_proto protoreflect.FileDescriptor
var file_models_rpc_messages_proto_rawDesc = []byte{
@@ -120,8 +168,10 @@ var file_models_rpc_messages_proto_rawDesc = []byte{
0x0c, 0x0a, 0x0a, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x28, 0x0a,
0x10, 0x52, 0x50, 0x43, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x23, 0x0a, 0x09, 0x52, 0x50, 0x43, 0x45, 0x78,
0x69, 0x73, 0x74, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73, 0x18, 0x01,
0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -136,10 +186,11 @@ func file_models_rpc_messages_proto_rawDescGZIP() []byte {
return file_models_rpc_messages_proto_rawDescData
}
var file_models_rpc_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
var file_models_rpc_messages_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
var file_models_rpc_messages_proto_goTypes = []interface{}{
(*RPCSuccess)(nil), // 0: pb.RPCSuccess
(*RPCCountResponse)(nil), // 1: pb.RPCCountResponse
(*RPCExists)(nil), // 2: pb.RPCExists
}
var file_models_rpc_messages_proto_depIdxs = []int32{
0, // [0:0] is the sub-list for method output_type
@@ -179,6 +230,18 @@ func file_models_rpc_messages_proto_init() {
return nil
}
}
file_models_rpc_messages_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RPCExists); 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{
@@ -186,7 +249,7 @@ func file_models_rpc_messages_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_models_rpc_messages_proto_rawDesc,
NumEnums: 0,
NumMessages: 2,
NumMessages: 3,
NumExtensions: 0,
NumServices: 0,
},

View File

@@ -0,0 +1,557 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.12.3
// source: service_metric_stat.proto
package pb
import (
context "context"
proto "github.com/golang/protobuf/proto"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
sync "sync"
)
const (
// Verify that this generated code is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
// Verify that runtime/protoimpl is sufficiently up-to-date.
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
// 上传统计数据
type UploadMetricStatsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
MetricStats []*MetricStat `protobuf:"bytes,1,rep,name=metricStats,proto3" json:"metricStats,omitempty"`
}
func (x *UploadMetricStatsRequest) Reset() {
*x = UploadMetricStatsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_metric_stat_proto_msgTypes[0]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *UploadMetricStatsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*UploadMetricStatsRequest) ProtoMessage() {}
func (x *UploadMetricStatsRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_metric_stat_proto_msgTypes[0]
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 UploadMetricStatsRequest.ProtoReflect.Descriptor instead.
func (*UploadMetricStatsRequest) Descriptor() ([]byte, []int) {
return file_service_metric_stat_proto_rawDescGZIP(), []int{0}
}
func (x *UploadMetricStatsRequest) GetMetricStats() []*MetricStat {
if x != nil {
return x.MetricStats
}
return nil
}
// 计算指标数据数量
type CountMetricStatsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
MetricItemId int64 `protobuf:"varint,1,opt,name=metricItemId,proto3" json:"metricItemId,omitempty"`
}
func (x *CountMetricStatsRequest) Reset() {
*x = CountMetricStatsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_metric_stat_proto_msgTypes[1]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *CountMetricStatsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*CountMetricStatsRequest) ProtoMessage() {}
func (x *CountMetricStatsRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_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 CountMetricStatsRequest.ProtoReflect.Descriptor instead.
func (*CountMetricStatsRequest) Descriptor() ([]byte, []int) {
return file_service_metric_stat_proto_rawDescGZIP(), []int{1}
}
func (x *CountMetricStatsRequest) GetMetricItemId() int64 {
if x != nil {
return x.MetricItemId
}
return 0
}
// 读取单页指标数据
type ListMetricStatsRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
MetricItemId int64 `protobuf:"varint,1,opt,name=metricItemId,proto3" json:"metricItemId,omitempty"`
Offset int64 `protobuf:"varint,2,opt,name=offset,proto3" json:"offset,omitempty"`
Size int64 `protobuf:"varint,3,opt,name=size,proto3" json:"size,omitempty"`
}
func (x *ListMetricStatsRequest) Reset() {
*x = ListMetricStatsRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_metric_stat_proto_msgTypes[2]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListMetricStatsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListMetricStatsRequest) ProtoMessage() {}
func (x *ListMetricStatsRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_metric_stat_proto_msgTypes[2]
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 ListMetricStatsRequest.ProtoReflect.Descriptor instead.
func (*ListMetricStatsRequest) Descriptor() ([]byte, []int) {
return file_service_metric_stat_proto_rawDescGZIP(), []int{2}
}
func (x *ListMetricStatsRequest) GetMetricItemId() int64 {
if x != nil {
return x.MetricItemId
}
return 0
}
func (x *ListMetricStatsRequest) GetOffset() int64 {
if x != nil {
return x.Offset
}
return 0
}
func (x *ListMetricStatsRequest) GetSize() int64 {
if x != nil {
return x.Size
}
return 0
}
type ListMetricStatsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
MetricStats []*MetricStat `protobuf:"bytes,1,rep,name=metricStats,proto3" json:"metricStats,omitempty"`
}
func (x *ListMetricStatsResponse) Reset() {
*x = ListMetricStatsResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_service_metric_stat_proto_msgTypes[3]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ListMetricStatsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListMetricStatsResponse) ProtoMessage() {}
func (x *ListMetricStatsResponse) ProtoReflect() protoreflect.Message {
mi := &file_service_metric_stat_proto_msgTypes[3]
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 ListMetricStatsResponse.ProtoReflect.Descriptor instead.
func (*ListMetricStatsResponse) Descriptor() ([]byte, []int) {
return file_service_metric_stat_proto_rawDescGZIP(), []int{3}
}
func (x *ListMetricStatsResponse) GetMetricStats() []*MetricStat {
if x != nil {
return x.MetricStats
}
return nil
}
var File_service_metric_stat_proto protoreflect.FileDescriptor
var file_service_metric_stat_proto_rawDesc = []byte{
0x0a, 0x19, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x5f, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63,
0x5f, 0x73, 0x74, 0x61, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x02, 0x70, 0x62, 0x1a,
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,
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 (
file_service_metric_stat_proto_rawDescOnce sync.Once
file_service_metric_stat_proto_rawDescData = file_service_metric_stat_proto_rawDesc
)
func file_service_metric_stat_proto_rawDescGZIP() []byte {
file_service_metric_stat_proto_rawDescOnce.Do(func() {
file_service_metric_stat_proto_rawDescData = protoimpl.X.CompressGZIP(file_service_metric_stat_proto_rawDescData)
})
return file_service_metric_stat_proto_rawDescData
}
var file_service_metric_stat_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_service_metric_stat_proto_goTypes = []interface{}{
(*UploadMetricStatsRequest)(nil), // 0: pb.UploadMetricStatsRequest
(*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
}
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
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
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
2, // [2:2] is the sub-list for extension type_name
2, // [2:2] is the sub-list for extension extendee
0, // [0:2] is the sub-list for field type_name
}
func init() { file_service_metric_stat_proto_init() }
func file_service_metric_stat_proto_init() {
if File_service_metric_stat_proto != nil {
return
}
file_models_model_metric_stat_proto_init()
file_models_rpc_messages_proto_init()
if !protoimpl.UnsafeEnabled {
file_service_metric_stat_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UploadMetricStatsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_metric_stat_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*CountMetricStatsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_metric_stat_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListMetricStatsRequest); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_service_metric_stat_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ListMetricStatsResponse); 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{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_metric_stat_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_service_metric_stat_proto_goTypes,
DependencyIndexes: file_service_metric_stat_proto_depIdxs,
MessageInfos: file_service_metric_stat_proto_msgTypes,
}.Build()
File_service_metric_stat_proto = out.File
file_service_metric_stat_proto_rawDesc = nil
file_service_metric_stat_proto_goTypes = nil
file_service_metric_stat_proto_depIdxs = nil
}
// Reference imports to suppress errors if they are not otherwise used.
var _ context.Context
var _ grpc.ClientConnInterface
// This is a compile-time assertion to ensure that this generated file
// is compatible with the grpc package it is being compiled against.
const _ = grpc.SupportPackageIsVersion6
// MetricStatServiceClient is the client API for MetricStatService service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type MetricStatServiceClient interface {
// 上传统计数据
UploadMetricStats(ctx context.Context, in *UploadMetricStatsRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
// 计算指标数据数量
CountMetricStats(ctx context.Context, in *CountMetricStatsRequest, opts ...grpc.CallOption) (*RPCCountResponse, error)
// 读取单页指标数据
ListMetricStats(ctx context.Context, in *ListMetricStatsRequest, opts ...grpc.CallOption) (*ListMetricStatsResponse, error)
}
type metricStatServiceClient struct {
cc grpc.ClientConnInterface
}
func NewMetricStatServiceClient(cc grpc.ClientConnInterface) MetricStatServiceClient {
return &metricStatServiceClient{cc}
}
func (c *metricStatServiceClient) UploadMetricStats(ctx context.Context, in *UploadMetricStatsRequest, opts ...grpc.CallOption) (*RPCSuccess, error) {
out := new(RPCSuccess)
err := c.cc.Invoke(ctx, "/pb.MetricStatService/uploadMetricStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *metricStatServiceClient) CountMetricStats(ctx context.Context, in *CountMetricStatsRequest, opts ...grpc.CallOption) (*RPCCountResponse, error) {
out := new(RPCCountResponse)
err := c.cc.Invoke(ctx, "/pb.MetricStatService/countMetricStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *metricStatServiceClient) ListMetricStats(ctx context.Context, in *ListMetricStatsRequest, opts ...grpc.CallOption) (*ListMetricStatsResponse, error) {
out := new(ListMetricStatsResponse)
err := c.cc.Invoke(ctx, "/pb.MetricStatService/listMetricStats", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// MetricStatServiceServer is the server API for MetricStatService service.
type MetricStatServiceServer interface {
// 上传统计数据
UploadMetricStats(context.Context, *UploadMetricStatsRequest) (*RPCSuccess, error)
// 计算指标数据数量
CountMetricStats(context.Context, *CountMetricStatsRequest) (*RPCCountResponse, error)
// 读取单页指标数据
ListMetricStats(context.Context, *ListMetricStatsRequest) (*ListMetricStatsResponse, error)
}
// UnimplementedMetricStatServiceServer can be embedded to have forward compatible implementations.
type UnimplementedMetricStatServiceServer struct {
}
func (*UnimplementedMetricStatServiceServer) UploadMetricStats(context.Context, *UploadMetricStatsRequest) (*RPCSuccess, error) {
return nil, status.Errorf(codes.Unimplemented, "method UploadMetricStats not implemented")
}
func (*UnimplementedMetricStatServiceServer) CountMetricStats(context.Context, *CountMetricStatsRequest) (*RPCCountResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CountMetricStats not implemented")
}
func (*UnimplementedMetricStatServiceServer) ListMetricStats(context.Context, *ListMetricStatsRequest) (*ListMetricStatsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method ListMetricStats not implemented")
}
func RegisterMetricStatServiceServer(s *grpc.Server, srv MetricStatServiceServer) {
s.RegisterService(&_MetricStatService_serviceDesc, srv)
}
func _MetricStatService_UploadMetricStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(UploadMetricStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MetricStatServiceServer).UploadMetricStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.MetricStatService/UploadMetricStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MetricStatServiceServer).UploadMetricStats(ctx, req.(*UploadMetricStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _MetricStatService_CountMetricStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(CountMetricStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MetricStatServiceServer).CountMetricStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.MetricStatService/CountMetricStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MetricStatServiceServer).CountMetricStats(ctx, req.(*CountMetricStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
func _MetricStatService_ListMetricStats_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListMetricStatsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(MetricStatServiceServer).ListMetricStats(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.MetricStatService/ListMetricStats",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(MetricStatServiceServer).ListMetricStats(ctx, req.(*ListMetricStatsRequest))
}
return interceptor(ctx, in, info, handler)
}
var _MetricStatService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.MetricStatService",
HandlerType: (*MetricStatServiceServer)(nil),
Methods: []grpc.MethodDesc{
{
MethodName: "uploadMetricStats",
Handler: _MetricStatService_UploadMetricStats_Handler,
},
{
MethodName: "countMetricStats",
Handler: _MetricStatService_CountMetricStats_Handler,
},
{
MethodName: "listMetricStats",
Handler: _MetricStatService_ListMetricStats_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_metric_stat.proto",
}

View File

@@ -148,6 +148,7 @@ type FindAllNodeClusterMetricItemsRequest struct {
unknownFields protoimpl.UnknownFields
NodeClusterId int64 `protobuf:"varint,1,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"`
Category string `protobuf:"bytes,2,opt,name=category,proto3" json:"category,omitempty"`
}
func (x *FindAllNodeClusterMetricItemsRequest) Reset() {
@@ -189,6 +190,13 @@ func (x *FindAllNodeClusterMetricItemsRequest) GetNodeClusterId() int64 {
return 0
}
func (x *FindAllNodeClusterMetricItemsRequest) GetCategory() string {
if x != nil {
return x.Category
}
return ""
}
type FindAllNodeClusterMetricItemsResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@@ -236,6 +244,62 @@ func (x *FindAllNodeClusterMetricItemsResponse) GetMetricItems() []*MetricItem {
return nil
}
// 检查是否已添加某个指标
type ExistsNodeClusterMetricItemRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
NodeClusterId int64 `protobuf:"varint,1,opt,name=nodeClusterId,proto3" json:"nodeClusterId,omitempty"`
MetricItemId int64 `protobuf:"varint,2,opt,name=metricItemId,proto3" json:"metricItemId,omitempty"`
}
func (x *ExistsNodeClusterMetricItemRequest) Reset() {
*x = ExistsNodeClusterMetricItemRequest{}
if protoimpl.UnsafeEnabled {
mi := &file_service_node_cluster_metric_item_proto_msgTypes[4]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ExistsNodeClusterMetricItemRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ExistsNodeClusterMetricItemRequest) ProtoMessage() {}
func (x *ExistsNodeClusterMetricItemRequest) ProtoReflect() protoreflect.Message {
mi := &file_service_node_cluster_metric_item_proto_msgTypes[4]
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 ExistsNodeClusterMetricItemRequest.ProtoReflect.Descriptor instead.
func (*ExistsNodeClusterMetricItemRequest) Descriptor() ([]byte, []int) {
return file_service_node_cluster_metric_item_proto_rawDescGZIP(), []int{4}
}
func (x *ExistsNodeClusterMetricItemRequest) GetNodeClusterId() int64 {
if x != nil {
return x.NodeClusterId
}
return 0
}
func (x *ExistsNodeClusterMetricItemRequest) GetMetricItemId() int64 {
if x != nil {
return x.MetricItemId
}
return 0
}
var File_service_node_cluster_metric_item_proto protoreflect.FileDescriptor
var file_service_node_cluster_metric_item_proto_rawDesc = []byte{
@@ -259,39 +323,53 @@ var file_service_node_cluster_metric_item_proto_rawDesc = []byte{
0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74,
0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74,
0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x6d, 0x65, 0x74, 0x72,
0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x22, 0x4c, 0x0a, 0x24, 0x46, 0x69, 0x6e, 0x64,
0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x22, 0x68, 0x0a, 0x24, 0x46, 0x69, 0x6e, 0x64,
0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65,
0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74,
0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49,
0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75,
0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x22, 0x59, 0x0a, 0x25, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c,
0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72,
0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x30, 0x0a, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63,
0x49, 0x74, 0x65, 0x6d, 0x52, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d,
0x73, 0x32, 0xc4, 0x02, 0x0a, 0x1c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65,
0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69,
0x63, 0x65, 0x12, 0x55, 0x0a, 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65,
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65,
0x6d, 0x12, 0x26, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64,
0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f,
0x72, 0x79, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x61, 0x74, 0x65, 0x67, 0x6f,
0x72, 0x79, 0x22, 0x59, 0x0a, 0x25, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64,
0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74,
0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52,
0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x57, 0x0a, 0x1c, 0x64, 0x69, 0x73,
0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d,
0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x44,
0x69, 0x73, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65,
0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65,
0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65,
0x73, 0x73, 0x12, 0x74, 0x0a, 0x1d, 0x66, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64,
0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74,
0x65, 0x6d, 0x73, 0x12, 0x28, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c,
0x65, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x6d,
0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
0x32, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d,
0x52, 0x0b, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x6e, 0x0a,
0x22, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74,
0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x75,
0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x0d, 0x6e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74,
0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0d, 0x6e, 0x6f, 0x64, 0x65,
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x49, 0x64, 0x12, 0x22, 0x0a, 0x0c, 0x6d, 0x65, 0x74,
0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
0x0c, 0x6d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x32, 0x9a, 0x03,
0x0a, 0x1c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74,
0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x55,
0x0a, 0x1b, 0x65, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73,
0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x26, 0x2e,
0x70, 0x62, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75,
0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e, 0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75,
0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x57, 0x0a, 0x1c, 0x64, 0x69, 0x73, 0x61, 0x62, 0x6c, 0x65,
0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69,
0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e,
0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c,
0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 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,
0x63, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x27, 0x2e, 0x70, 0x62, 0x2e, 0x44, 0x69, 0x73, 0x61, 0x62,
0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74,
0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0e,
0x2e, 0x70, 0x62, 0x2e, 0x52, 0x50, 0x43, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x12, 0x74,
0x0a, 0x1d, 0x66, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75,
0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x12,
0x28, 0x2e, 0x70, 0x62, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64, 0x65,
0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65,
0x6d, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x70, 0x62, 0x2e, 0x46,
0x69, 0x6e, 0x64, 0x41, 0x6c, 0x6c, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65,
0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x52, 0x65, 0x73, 0x70,
0x6f, 0x6e, 0x73, 0x65, 0x12, 0x54, 0x0a, 0x1b, 0x65, 0x78, 0x69, 0x73, 0x74, 0x73, 0x4e, 0x6f,
0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63, 0x49,
0x74, 0x65, 0x6d, 0x12, 0x26, 0x2e, 0x70, 0x62, 0x2e, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x4e,
0x6f, 0x64, 0x65, 0x43, 0x6c, 0x75, 0x73, 0x74, 0x65, 0x72, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63,
0x49, 0x74, 0x65, 0x6d, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x0d, 0x2e, 0x70, 0x62,
0x2e, 0x52, 0x50, 0x43, 0x45, 0x78, 0x69, 0x73, 0x74, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x2f,
0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@@ -306,25 +384,29 @@ func file_service_node_cluster_metric_item_proto_rawDescGZIP() []byte {
return file_service_node_cluster_metric_item_proto_rawDescData
}
var file_service_node_cluster_metric_item_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_service_node_cluster_metric_item_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_service_node_cluster_metric_item_proto_goTypes = []interface{}{
(*EnableNodeClusterMetricItemRequest)(nil), // 0: pb.EnableNodeClusterMetricItemRequest
(*DisableNodeClusterMetricItemRequest)(nil), // 1: pb.DisableNodeClusterMetricItemRequest
(*FindAllNodeClusterMetricItemsRequest)(nil), // 2: pb.FindAllNodeClusterMetricItemsRequest
(*FindAllNodeClusterMetricItemsResponse)(nil), // 3: pb.FindAllNodeClusterMetricItemsResponse
(*MetricItem)(nil), // 4: pb.MetricItem
(*RPCSuccess)(nil), // 5: pb.RPCSuccess
(*ExistsNodeClusterMetricItemRequest)(nil), // 4: pb.ExistsNodeClusterMetricItemRequest
(*MetricItem)(nil), // 5: pb.MetricItem
(*RPCSuccess)(nil), // 6: pb.RPCSuccess
(*RPCExists)(nil), // 7: pb.RPCExists
}
var file_service_node_cluster_metric_item_proto_depIdxs = []int32{
4, // 0: pb.FindAllNodeClusterMetricItemsResponse.metricItems:type_name -> pb.MetricItem
5, // 0: pb.FindAllNodeClusterMetricItemsResponse.metricItems:type_name -> pb.MetricItem
0, // 1: pb.NodeClusterMetricItemService.enableNodeClusterMetricItem:input_type -> pb.EnableNodeClusterMetricItemRequest
1, // 2: pb.NodeClusterMetricItemService.disableNodeClusterMetricItem:input_type -> pb.DisableNodeClusterMetricItemRequest
2, // 3: pb.NodeClusterMetricItemService.findAllNodeClusterMetricItems:input_type -> pb.FindAllNodeClusterMetricItemsRequest
5, // 4: pb.NodeClusterMetricItemService.enableNodeClusterMetricItem:output_type -> pb.RPCSuccess
5, // 5: pb.NodeClusterMetricItemService.disableNodeClusterMetricItem:output_type -> pb.RPCSuccess
3, // 6: pb.NodeClusterMetricItemService.findAllNodeClusterMetricItems:output_type -> pb.FindAllNodeClusterMetricItemsResponse
4, // [4:7] is the sub-list for method output_type
1, // [1:4] is the sub-list for method input_type
4, // 4: pb.NodeClusterMetricItemService.existsNodeClusterMetricItem:input_type -> pb.ExistsNodeClusterMetricItemRequest
6, // 5: pb.NodeClusterMetricItemService.enableNodeClusterMetricItem:output_type -> pb.RPCSuccess
6, // 6: pb.NodeClusterMetricItemService.disableNodeClusterMetricItem:output_type -> pb.RPCSuccess
3, // 7: pb.NodeClusterMetricItemService.findAllNodeClusterMetricItems:output_type -> pb.FindAllNodeClusterMetricItemsResponse
7, // 8: pb.NodeClusterMetricItemService.existsNodeClusterMetricItem:output_type -> pb.RPCExists
5, // [5:9] is the sub-list for method output_type
1, // [1:5] is the sub-list for method input_type
1, // [1:1] is the sub-list for extension type_name
1, // [1:1] is the sub-list for extension extendee
0, // [0:1] is the sub-list for field type_name
@@ -386,6 +468,18 @@ func file_service_node_cluster_metric_item_proto_init() {
return nil
}
}
file_service_node_cluster_metric_item_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ExistsNodeClusterMetricItemRequest); 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{
@@ -393,7 +487,7 @@ func file_service_node_cluster_metric_item_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_service_node_cluster_metric_item_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 5,
NumExtensions: 0,
NumServices: 1,
},
@@ -425,6 +519,8 @@ type NodeClusterMetricItemServiceClient interface {
DisableNodeClusterMetricItem(ctx context.Context, in *DisableNodeClusterMetricItemRequest, opts ...grpc.CallOption) (*RPCSuccess, error)
// 查找集群中所有指标
FindAllNodeClusterMetricItems(ctx context.Context, in *FindAllNodeClusterMetricItemsRequest, opts ...grpc.CallOption) (*FindAllNodeClusterMetricItemsResponse, error)
// 检查是否已添加某个指标
ExistsNodeClusterMetricItem(ctx context.Context, in *ExistsNodeClusterMetricItemRequest, opts ...grpc.CallOption) (*RPCExists, error)
}
type nodeClusterMetricItemServiceClient struct {
@@ -462,6 +558,15 @@ func (c *nodeClusterMetricItemServiceClient) FindAllNodeClusterMetricItems(ctx c
return out, nil
}
func (c *nodeClusterMetricItemServiceClient) ExistsNodeClusterMetricItem(ctx context.Context, in *ExistsNodeClusterMetricItemRequest, opts ...grpc.CallOption) (*RPCExists, error) {
out := new(RPCExists)
err := c.cc.Invoke(ctx, "/pb.NodeClusterMetricItemService/existsNodeClusterMetricItem", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// NodeClusterMetricItemServiceServer is the server API for NodeClusterMetricItemService service.
type NodeClusterMetricItemServiceServer interface {
// 启用某个指标
@@ -470,6 +575,8 @@ type NodeClusterMetricItemServiceServer interface {
DisableNodeClusterMetricItem(context.Context, *DisableNodeClusterMetricItemRequest) (*RPCSuccess, error)
// 查找集群中所有指标
FindAllNodeClusterMetricItems(context.Context, *FindAllNodeClusterMetricItemsRequest) (*FindAllNodeClusterMetricItemsResponse, error)
// 检查是否已添加某个指标
ExistsNodeClusterMetricItem(context.Context, *ExistsNodeClusterMetricItemRequest) (*RPCExists, error)
}
// UnimplementedNodeClusterMetricItemServiceServer can be embedded to have forward compatible implementations.
@@ -485,6 +592,9 @@ func (*UnimplementedNodeClusterMetricItemServiceServer) DisableNodeClusterMetric
func (*UnimplementedNodeClusterMetricItemServiceServer) FindAllNodeClusterMetricItems(context.Context, *FindAllNodeClusterMetricItemsRequest) (*FindAllNodeClusterMetricItemsResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method FindAllNodeClusterMetricItems not implemented")
}
func (*UnimplementedNodeClusterMetricItemServiceServer) ExistsNodeClusterMetricItem(context.Context, *ExistsNodeClusterMetricItemRequest) (*RPCExists, error) {
return nil, status.Errorf(codes.Unimplemented, "method ExistsNodeClusterMetricItem not implemented")
}
func RegisterNodeClusterMetricItemServiceServer(s *grpc.Server, srv NodeClusterMetricItemServiceServer) {
s.RegisterService(&_NodeClusterMetricItemService_serviceDesc, srv)
@@ -544,6 +654,24 @@ func _NodeClusterMetricItemService_FindAllNodeClusterMetricItems_Handler(srv int
return interceptor(ctx, in, info, handler)
}
func _NodeClusterMetricItemService_ExistsNodeClusterMetricItem_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ExistsNodeClusterMetricItemRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(NodeClusterMetricItemServiceServer).ExistsNodeClusterMetricItem(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/pb.NodeClusterMetricItemService/ExistsNodeClusterMetricItem",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(NodeClusterMetricItemServiceServer).ExistsNodeClusterMetricItem(ctx, req.(*ExistsNodeClusterMetricItemRequest))
}
return interceptor(ctx, in, info, handler)
}
var _NodeClusterMetricItemService_serviceDesc = grpc.ServiceDesc{
ServiceName: "pb.NodeClusterMetricItemService",
HandlerType: (*NodeClusterMetricItemServiceServer)(nil),
@@ -560,6 +688,10 @@ var _NodeClusterMetricItemService_serviceDesc = grpc.ServiceDesc{
MethodName: "findAllNodeClusterMetricItems",
Handler: _NodeClusterMetricItemService_FindAllNodeClusterMetricItems_Handler,
},
{
MethodName: "existsNodeClusterMetricItem",
Handler: _NodeClusterMetricItemService_ExistsNodeClusterMetricItem_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "service_node_cluster_metric_item.proto",

View File

@@ -0,0 +1,24 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "models/model_node_cluster.proto";
import "models/model_node.proto";
import "models/model_server.proto";
// 统计数据
message MetricStat {
int64 id = 1;
string hash = 2;
int64 serverId = 3;
int64 itemId = 4;
repeated string keys = 5;
float value = 6;
string time = 7;
int32 version = 8;
NodeCluster nodeCluster = 30;
Node node = 31;
Server server = 32;
}

View File

@@ -12,3 +12,8 @@ message RPCSuccess {
message RPCCountResponse {
int64 count = 1;
}
// 是否存在
message RPCExists {
bool exists = 1;
}

View File

@@ -0,0 +1,39 @@
syntax = "proto3";
option go_package = "./pb";
package pb;
import "models/model_metric_stat.proto";
import "models/rpc_messages.proto";
// 指标统计数据相关服务
service MetricStatService {
// 上传统计数据
rpc uploadMetricStats (UploadMetricStatsRequest) returns (RPCSuccess);
// 计算指标数据数量
rpc countMetricStats (CountMetricStatsRequest) returns (RPCCountResponse);
// 读取单页指标数据
rpc listMetricStats (ListMetricStatsRequest) returns (ListMetricStatsResponse);
}
// 上传统计数据
message UploadMetricStatsRequest {
repeated MetricStat metricStats = 1;
}
// 计算指标数据数量
message CountMetricStatsRequest {
int64 metricItemId = 1;
}
// 读取单页指标数据
message ListMetricStatsRequest {
int64 metricItemId = 1;
int64 offset = 2;
int64 size = 3;
}
message ListMetricStatsResponse {
repeated MetricStat metricStats = 1;
}

View File

@@ -16,6 +16,9 @@ service NodeClusterMetricItemService {
// 查找集群中所有指标
rpc findAllNodeClusterMetricItems (FindAllNodeClusterMetricItemsRequest) returns (FindAllNodeClusterMetricItemsResponse);
// 检查是否已添加某个指标
rpc existsNodeClusterMetricItem (ExistsNodeClusterMetricItemRequest) returns (RPCExists);
}
// 启用某个指标
@@ -33,8 +36,15 @@ message DisableNodeClusterMetricItemRequest {
// 查找集群中所有指标
message FindAllNodeClusterMetricItemsRequest {
int64 nodeClusterId = 1;
string category = 2;
}
message FindAllNodeClusterMetricItemsResponse {
repeated MetricItem metricItems = 1;
}
// 检查是否已添加某个指标
message ExistsNodeClusterMetricItemRequest {
int64 nodeClusterId = 1;
int64 metricItemId = 2;
}

View File

@@ -3,29 +3,8 @@
package serverconfigs
import (
"github.com/cespare/xxhash/v2"
"github.com/iwind/TeaGo/types"
"strconv"
)
// MetricItemCategory 指标分类
type MetricItemCategory = string
const (
MetricItemCategoryHTTP MetricItemCategory = "http"
MetricItemCategoryTCP MetricItemCategory = "tcp"
MetricItemCategoryUDP MetricItemCategory = "udp"
)
// MetricItemPeriodUnit 指标周期单位
type MetricItemPeriodUnit = string
const (
MetricItemPeriodUnitMinute MetricItemPeriodUnit = "minute"
MetricItemPeriodUnitHour MetricItemPeriodUnit = "hour"
MetricItemPeriodUnitDay MetricItemPeriodUnit = "day"
MetricItemPeriodUnitWeek MetricItemPeriodUnit = "week"
MetricItemPeriodUnitMonth MetricItemPeriodUnit = "month"
timeutil "github.com/iwind/TeaGo/utils/time"
"time"
)
// MetricItemConfig 指标配置
@@ -33,32 +12,147 @@ type MetricItemConfig struct {
Id int64 `yaml:"id" json:"id"`
IsOn bool `yaml:"isOn" json:"isOn"`
Category MetricItemCategory `yaml:"category" json:"category"`
Period int `yaml:"period" json:"period"`
Period int `yaml:"period" json:"period"` // 单个周期
PeriodUnit MetricItemPeriodUnit `yaml:"periodUnit" json:"periodUnit"`
Keys []string `yaml:"keys" json:"keys"`
Value string `yaml:"value" json:"value"`
Version int `yaml:"version" json:"version"`
sumType string // 统计类型
baseTime time.Time // 基准时间
hasHTTPConnectionValue bool // 是否有统计HTTP连接数的数值
}
// Init 初始化
func (this *MetricItemConfig) Init() error {
// 所有时间以 2020-01-01日 为基准
this.baseTime = time.Date(2020, 1, 1, 0, 0, 0, 0, time.Local)
if this.Period <= 0 {
this.Period = 1
}
if len(this.PeriodUnit) == 0 {
this.PeriodUnit = MetricItemPeriodUnitDay
}
this.hasHTTPConnectionValue = this.Category == MetricItemCategoryHTTP && this.Value == "${countConnection}"
return nil
}
// ParseRequest 处理请求
func (this *MetricItemConfig) ParseRequest(format func(string) string) (key string, hash string, value float64) {
for _, k := range this.Keys {
key += "@" + format(k)
}
hash = strconv.FormatUint(xxhash.Sum64String(key), 10)
// CurrentTime 根据周期计算时间
func (this *MetricItemConfig) CurrentTime() string {
var t string
// TODO value将来支持复杂运算比如 ${request.traffic.bytes} * 8
if len(this.Value) == 0 {
value = 1
switch this.PeriodUnit {
case MetricItemPeriodUnitMonth:
if this.Period > 1 {
var now = time.Now()
var months = (now.Year()-this.baseTime.Year())*12 + int(now.Month())
var delta = months % this.Period
if delta == 0 {
t = timeutil.Format("Ym")
} else {
value = types.Float64(format(this.Value))
t = timeutil.Format("Ym", now.AddDate(0, -delta, 0))
}
return
} else {
t = timeutil.Format("Ym")
}
case MetricItemPeriodUnitWeek:
if this.Period > 1 {
var now = time.Now()
var weeks = int((now.Unix() - this.baseTime.Unix()) / (86400 * 7))
var delta = weeks % this.Period
if delta == 0 {
t = timeutil.Format("YW")
} else {
t = timeutil.FormatTime("YW", now.Unix()-int64(delta*7*86400))
}
} else {
t = timeutil.Format("YW")
}
case MetricItemPeriodUnitDay:
if this.Period > 1 {
var now = time.Now()
var days = int((now.Unix() - this.baseTime.Unix()) / 86400)
var delta = days % this.Period
if delta == 0 {
t = timeutil.Format("Ymd")
} else {
t = timeutil.FormatTime("Ymd", now.Unix()-int64(delta*86400))
}
} else {
t = timeutil.Format("Ymd")
}
case MetricItemPeriodUnitHour:
if this.Period > 1 {
var now = time.Now()
var hours = int((now.Unix() - this.baseTime.Unix()) / 3600)
var delta = hours % this.Period
if delta == 0 {
t = timeutil.Format("YmdH")
} else {
t = timeutil.FormatTime("YmdH", now.Unix()-int64(delta*3600))
}
} else {
t = timeutil.Format("YmdH")
}
case MetricItemPeriodUnitMinute:
if this.Period > 1 {
var now = time.Now()
var minutes = int((now.Unix() - this.baseTime.Unix()) / 60)
var delta = minutes % this.Period
if delta == 0 {
t = timeutil.Format("YmdHi")
} else {
t = timeutil.FormatTime("YmdHi", now.Unix()-int64(delta*60))
}
} else {
t = timeutil.Format("YmdHi")
}
default:
return ""
}
return t
}
// ExpiresTime 根据周期计算过期时间
func (this *MetricItemConfig) ExpiresTime() string {
switch this.PeriodUnit {
case MetricItemPeriodUnitMonth:
return timeutil.Format("Ym", time.Now().AddDate(0, -(this.Period*4), 0))
case MetricItemPeriodUnitWeek:
return timeutil.FormatTime("YW", time.Now().Unix()-86400*7*int64(this.Period*5))
case MetricItemPeriodUnitDay:
return timeutil.FormatTime("Ymd", time.Now().Unix()-86400*int64(this.Period*32))
case MetricItemPeriodUnitHour:
return timeutil.FormatTime("YmdH", time.Now().Unix()-3600*int64(this.Period*25))
case MetricItemPeriodUnitMinute:
return timeutil.FormatTime("YmdHi", time.Now().Unix()-60*int64(this.Period*60))
default:
return ""
}
}
// UploadDuration 上传数据的周期
func (this *MetricItemConfig) UploadDuration() time.Duration {
switch this.PeriodUnit {
case MetricItemPeriodUnitMonth:
return 10 * time.Minute
case MetricItemPeriodUnitWeek:
return 10 * time.Minute
case MetricItemPeriodUnitDay:
return 10 * time.Minute
case MetricItemPeriodUnitHour:
return 5 * time.Minute
case MetricItemPeriodUnitMinute:
return time.Duration(this.Period) * time.Minute
default:
return 10 * time.Minute
}
}
func (this *MetricItemConfig) HasHTTPConnectionValue() bool {
return this.hasHTTPConnectionValue
}

View File

@@ -2,38 +2,59 @@
package serverconfigs
import (
"github.com/TeaOSLab/EdgeCommon/pkg/configutils"
"testing"
)
import "testing"
func TestMetricItemConfig_ProcessRequest(t *testing.T) {
var metric = &MetricItemConfig{
Keys: []string{"${remoteAddr}", "${status}", "${requestPath}"},
Value: "${trafficIn}",
func TestMetricItemConfig_CurrentTime_Month(t *testing.T) {
for _, period := range []int{1, 2, 3, 4, 5, 100} {
var item = &MetricItemConfig{
Period: period,
PeriodUnit: MetricItemPeriodUnitMonth,
}
key, hash, value := metric.ParseRequest(func(s string) string {
return configutils.ParseVariables(s, func(varName string) (value string) {
switch varName {
case "trafficIn":
return "1000"
_ = item.Init()
t.Logf(item.CurrentTime())
}
return "[" + varName + "]"
})
})
t.Log("key:", key, "hash:", hash)
t.Logf("value: %f", value)
}
func BenchmarkMetricItemConfig_ProcessRequest(b *testing.B) {
var metric = &MetricItemConfig{
Keys: []string{"${remoteAddr}", "${status}"},
func TestMetricItemConfig_CurrentTime_Week(t *testing.T) {
for _, period := range []int{1, 2, 3, 4, 5} {
var item = &MetricItemConfig{
Period: period,
PeriodUnit: MetricItemPeriodUnitWeek,
}
for i := 0; i < b.N; i++ {
metric.ParseRequest(func(s string) string {
return configutils.ParseVariables(s, func(varName string) (value string) {
return "[" + varName + "]"
})
})
_ = item.Init()
t.Log(period, ":", item.CurrentTime())
}
}
func TestMetricItemConfig_CurrentTime_Day(t *testing.T) {
for _, period := range []int{1, 2, 3, 4, 5, 13} {
var item = &MetricItemConfig{
Period: period,
PeriodUnit: MetricItemPeriodUnitDay,
}
_ = item.Init()
t.Log(period, ":", item.CurrentTime())
}
}
func TestMetricItemConfig_CurrentTime_Hour(t *testing.T) {
for _, period := range []int{1, 2, 3, 4, 5, 13} {
var item = &MetricItemConfig{
Period: period,
PeriodUnit: MetricItemPeriodUnitHour,
}
_ = item.Init()
t.Log(period, ":", item.CurrentTime())
}
}
func TestMetricItemConfig_CurrentTime_Minute(t *testing.T) {
for _, period := range []int{1, 2, 3, 4, 5, 13} {
var item = &MetricItemConfig{
Period: period,
PeriodUnit: MetricItemPeriodUnitMinute,
}
_ = item.Init()
t.Log(period, ":", item.CurrentTime())
}
}

View File

@@ -0,0 +1,143 @@
// Copyright 2021 Liuxiangchao iwind.liu@gmail.com. All rights reserved.
package serverconfigs
// MetricItemCategory 指标分类
type MetricItemCategory = string
const (
MetricItemCategoryHTTP MetricItemCategory = "http"
MetricItemCategoryTCP MetricItemCategory = "tcp"
MetricItemCategoryUDP MetricItemCategory = "udp"
)
// MetricItemPeriodUnit 指标周期单位
type MetricItemPeriodUnit = string
const (
MetricItemPeriodUnitMinute MetricItemPeriodUnit = "minute"
MetricItemPeriodUnitHour MetricItemPeriodUnit = "hour"
MetricItemPeriodUnitDay MetricItemPeriodUnit = "day"
MetricItemPeriodUnitWeek MetricItemPeriodUnit = "week"
MetricItemPeriodUnitMonth MetricItemPeriodUnit = "month"
)
// HTTP相关指标对象
type metricKeyDefinition struct {
Name string `json:"name"`
Code string `json:"code"`
Description string `json:"description"`
}
type metricValueDefinition struct {
Name string `json:"name"`
Code string `json:"code"`
Description string `json:"description"`
}
func FindAllHTTPMetricKeyDefinitions() []*metricKeyDefinition {
// TODO
return nil
}
func FindAllMetricValueDefinitions(category MetricItemCategory) []*metricValueDefinition {
switch category {
case MetricItemCategoryHTTP:
return []*metricValueDefinition{
{
Name: "请求数",
Code: "${countRequest}",
},
{
Name: "连接数",
Code: "${countConnection}",
},
{
Name: "下行流量",
Code: "${countTrafficOut}",
},
{
Name: "上行流量",
Code: "${countTrafficIn}",
},
}
case MetricItemCategoryTCP:
return []*metricValueDefinition{
{
Name: "连接数",
Code: "${countConnection}",
},
{
Name: "下行流量",
Code: "${countTrafficOut}",
},
{
Name: "上行流量",
Code: "${countTrafficIn}",
},
}
case MetricItemCategoryUDP:
return []*metricValueDefinition{
{
Name: "连接数",
Code: "${countConnection}",
},
{
Name: "下行流量",
Code: "${countTrafficOut}",
},
{
Name: "上行流量",
Code: "${countTrafficIn}",
},
}
}
return []*metricValueDefinition{}
}
// FindAllTCPMetricKeyDefinitions TCP相关指标对象
func FindAllTCPMetricKeyDefinitions() []*metricKeyDefinition {
// TODO
return nil
}
// FindAllUDPMetricKeyDefinitions UDP相关指标对象
func FindAllUDPMetricKeyDefinitions() []*metricKeyDefinition {
// TODO
return nil
}
// HumanMetricTime 格式化时间,让时间更易读
func HumanMetricTime(periodUnit MetricItemPeriodUnit, time string) string {
switch periodUnit {
case MetricItemPeriodUnitMonth:
if len(time) != 6 {
return time
}
return time[:4] + "-" + time[4:]
case MetricItemPeriodUnitWeek:
if len(time) != 6 {
return time
}
return time[:4] + "-" + time[4:]
case MetricItemPeriodUnitDay:
if len(time) != 8 {
return time
}
return time[:4] + "-" + time[4:6] + "-" + time[6:]
case MetricItemPeriodUnitHour:
if len(time) != 10 {
return time
}
return time[:4] + "-" + time[4:6] + "-" + time[6:8] + " " + time[8:]
case MetricItemPeriodUnitMinute:
if len(time) != 12 {
return time
}
return time[:4] + "-" + time[4:6] + "-" + time[6:8] + " " + time[8:10] + ":" + time[10:]
}
return time
}