diff --git a/internal/agent/client.go b/internal/agent/client.go index 4193f1e41d66..060a42d0c8d4 100644 --- a/internal/agent/client.go +++ b/internal/agent/client.go @@ -260,10 +260,11 @@ func (c *Client) StreamEvents(ctx context.Context, events chan<- container.Conta } events <- container.ContainerEvent{ - ActorID: resp.Event.ActorId, - Name: resp.Event.Name, - Host: resp.Event.Host, - Time: resp.Event.Timestamp.AsTime(), + ActorID: resp.Event.ActorId, + Name: resp.Event.Name, + Host: resp.Event.Host, + Time: resp.Event.Timestamp.AsTime(), + ActorAttributes: resp.Event.ActorAttributes, } } } @@ -531,6 +532,11 @@ func (c *Client) UpdateNotificationConfig(ctx context.Context, subscriptions []t Url: d.URL, Template: d.Template, Headers: d.Headers, + ApiKey: d.APIKey, + Prefix: d.Prefix, + } + if d.ExpiresAt != nil { + pbDispatchers[i].ExpiresAt = timestamppb.New(*d.ExpiresAt) } } diff --git a/internal/agent/pb/types.pb.go b/internal/agent/pb/types.pb.go index e9a102a75811..3dd762ea40c7 100644 --- a/internal/agent/pb/types.pb.go +++ b/internal/agent/pb/types.pb.go @@ -621,13 +621,14 @@ func (x *ComplexMessage) GetData() []byte { } type ContainerEvent struct { - state protoimpl.MessageState `protogen:"open.v1"` - ActorId string `protobuf:"bytes,1,opt,name=actorId,proto3" json:"actorId,omitempty"` - Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` - Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` - Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + ActorId string `protobuf:"bytes,1,opt,name=actorId,proto3" json:"actorId,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Host string `protobuf:"bytes,3,opt,name=host,proto3" json:"host,omitempty"` + Timestamp *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + ActorAttributes map[string]string `protobuf:"bytes,5,rep,name=actorAttributes,proto3" json:"actorAttributes,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ContainerEvent) Reset() { @@ -688,6 +689,13 @@ func (x *ContainerEvent) GetTimestamp() *timestamppb.Timestamp { return nil } +func (x *ContainerEvent) GetActorAttributes() map[string]string { + if x != nil { + return x.ActorAttributes + } + return nil +} + type Host struct { state protoimpl.MessageState `protogen:"open.v1"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` @@ -944,6 +952,9 @@ type NotificationDispatcher struct { Url string `protobuf:"bytes,4,opt,name=url,proto3" json:"url,omitempty"` Template string `protobuf:"bytes,5,opt,name=template,proto3" json:"template,omitempty"` Headers map[string]string `protobuf:"bytes,6,rep,name=headers,proto3" json:"headers,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` + ApiKey string `protobuf:"bytes,7,opt,name=apiKey,proto3" json:"apiKey,omitempty"` + Prefix string `protobuf:"bytes,8,opt,name=prefix,proto3" json:"prefix,omitempty"` + ExpiresAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=expiresAt,proto3" json:"expiresAt,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1020,6 +1031,27 @@ func (x *NotificationDispatcher) GetHeaders() map[string]string { return nil } +func (x *NotificationDispatcher) GetApiKey() string { + if x != nil { + return x.ApiKey + } + return "" +} + +func (x *NotificationDispatcher) GetPrefix() string { + if x != nil { + return x.Prefix + } + return "" +} + +func (x *NotificationDispatcher) GetExpiresAt() *timestamppb.Timestamp { + if x != nil { + return x.ExpiresAt + } + return nil +} + type NotificationSubscriptionStats struct { state protoimpl.MessageState `protogen:"open.v1"` SubscriptionId int32 `protobuf:"varint,1,opt,name=subscriptionId,proto3" json:"subscriptionId,omitempty"` @@ -1144,12 +1176,16 @@ const file_types_proto_rawDesc = "" + "\fGroupMessage\x123\n" + "\tfragments\x18\x01 \x03(\v2\x15.protobuf.LogFragmentR\tfragments\"$\n" + "\x0eComplexMessage\x12\x12\n" + - "\x04data\x18\x01 \x01(\fR\x04data\"\x8c\x01\n" + + "\x04data\x18\x01 \x01(\fR\x04data\"\xa9\x02\n" + "\x0eContainerEvent\x12\x18\n" + "\aactorId\x18\x01 \x01(\tR\aactorId\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" + "\x04host\x18\x03 \x01(\tR\x04host\x128\n" + - "\ttimestamp\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\"\xaf\x03\n" + + "\ttimestamp\x18\x04 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12W\n" + + "\x0factorAttributes\x18\x05 \x03(\v2-.protobuf.ContainerEvent.ActorAttributesEntryR\x0factorAttributes\x1aB\n" + + "\x14ActorAttributesEntry\x12\x10\n" + + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xaf\x03\n" + "\x04Host\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12 \n" + @@ -1178,14 +1214,17 @@ const file_types_proto_rawDesc = "" + "\bcooldown\x18\b \x01(\x05R\bcooldown\x12\"\n" + "\fsampleWindow\x18\t \x01(\x05R\fsampleWindow\x12(\n" + "\x0feventExpression\x18\n" + - " \x01(\tR\x0feventExpression\"\x83\x02\n" + + " \x01(\tR\x0feventExpression\"\xed\x02\n" + "\x16NotificationDispatcher\x12\x0e\n" + "\x02id\x18\x01 \x01(\x05R\x02id\x12\x12\n" + "\x04name\x18\x02 \x01(\tR\x04name\x12\x12\n" + "\x04type\x18\x03 \x01(\tR\x04type\x12\x10\n" + "\x03url\x18\x04 \x01(\tR\x03url\x12\x1a\n" + "\btemplate\x18\x05 \x01(\tR\btemplate\x12G\n" + - "\aheaders\x18\x06 \x03(\v2-.protobuf.NotificationDispatcher.HeadersEntryR\aheaders\x1a:\n" + + "\aheaders\x18\x06 \x03(\v2-.protobuf.NotificationDispatcher.HeadersEntryR\aheaders\x12\x16\n" + + "\x06apiKey\x18\a \x01(\tR\x06apiKey\x12\x16\n" + + "\x06prefix\x18\b \x01(\tR\x06prefix\x128\n" + + "\texpiresAt\x18\t \x01(\v2\x1a.google.protobuf.TimestampR\texpiresAt\x1a:\n" + "\fHeadersEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\xe7\x01\n" + @@ -1212,7 +1251,7 @@ func file_types_proto_rawDescGZIP() []byte { } var file_types_proto_enumTypes = make([]protoimpl.EnumInfo, 1) -var file_types_proto_msgTypes = make([]protoimpl.MessageInfo, 15) +var file_types_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_types_proto_goTypes = []any{ (ContainerAction)(0), // 0: protobuf.ContainerAction (*Container)(nil), // 1: protobuf.Container @@ -1228,29 +1267,32 @@ var file_types_proto_goTypes = []any{ (*NotificationDispatcher)(nil), // 11: protobuf.NotificationDispatcher (*NotificationSubscriptionStats)(nil), // 12: protobuf.NotificationSubscriptionStats nil, // 13: protobuf.Container.LabelsEntry - nil, // 14: protobuf.Host.LabelsEntry - nil, // 15: protobuf.NotificationDispatcher.HeadersEntry - (*timestamppb.Timestamp)(nil), // 16: google.protobuf.Timestamp - (*anypb.Any)(nil), // 17: google.protobuf.Any + nil, // 14: protobuf.ContainerEvent.ActorAttributesEntry + nil, // 15: protobuf.Host.LabelsEntry + nil, // 16: protobuf.NotificationDispatcher.HeadersEntry + (*timestamppb.Timestamp)(nil), // 17: google.protobuf.Timestamp + (*anypb.Any)(nil), // 18: google.protobuf.Any } var file_types_proto_depIdxs = []int32{ - 16, // 0: protobuf.Container.created:type_name -> google.protobuf.Timestamp - 16, // 1: protobuf.Container.started:type_name -> google.protobuf.Timestamp + 17, // 0: protobuf.Container.created:type_name -> google.protobuf.Timestamp + 17, // 1: protobuf.Container.started:type_name -> google.protobuf.Timestamp 13, // 2: protobuf.Container.labels:type_name -> protobuf.Container.LabelsEntry 2, // 3: protobuf.Container.stats:type_name -> protobuf.ContainerStat - 16, // 4: protobuf.Container.finished:type_name -> google.protobuf.Timestamp - 17, // 5: protobuf.LogEvent.message:type_name -> google.protobuf.Any - 16, // 6: protobuf.LogEvent.timestamp:type_name -> google.protobuf.Timestamp + 17, // 4: protobuf.Container.finished:type_name -> google.protobuf.Timestamp + 18, // 5: protobuf.LogEvent.message:type_name -> google.protobuf.Any + 17, // 6: protobuf.LogEvent.timestamp:type_name -> google.protobuf.Timestamp 3, // 7: protobuf.GroupMessage.fragments:type_name -> protobuf.LogFragment - 16, // 8: protobuf.ContainerEvent.timestamp:type_name -> google.protobuf.Timestamp - 14, // 9: protobuf.Host.labels:type_name -> protobuf.Host.LabelsEntry - 15, // 10: protobuf.NotificationDispatcher.headers:type_name -> protobuf.NotificationDispatcher.HeadersEntry - 16, // 11: protobuf.NotificationSubscriptionStats.lastTriggeredAt:type_name -> google.protobuf.Timestamp - 12, // [12:12] is the sub-list for method output_type - 12, // [12:12] is the sub-list for method input_type - 12, // [12:12] is the sub-list for extension type_name - 12, // [12:12] is the sub-list for extension extendee - 0, // [0:12] is the sub-list for field type_name + 17, // 8: protobuf.ContainerEvent.timestamp:type_name -> google.protobuf.Timestamp + 14, // 9: protobuf.ContainerEvent.actorAttributes:type_name -> protobuf.ContainerEvent.ActorAttributesEntry + 15, // 10: protobuf.Host.labels:type_name -> protobuf.Host.LabelsEntry + 16, // 11: protobuf.NotificationDispatcher.headers:type_name -> protobuf.NotificationDispatcher.HeadersEntry + 17, // 12: protobuf.NotificationDispatcher.expiresAt:type_name -> google.protobuf.Timestamp + 17, // 13: protobuf.NotificationSubscriptionStats.lastTriggeredAt:type_name -> google.protobuf.Timestamp + 14, // [14:14] is the sub-list for method output_type + 14, // [14:14] is the sub-list for method input_type + 14, // [14:14] is the sub-list for extension type_name + 14, // [14:14] is the sub-list for extension extendee + 0, // [0:14] is the sub-list for field type_name } func init() { file_types_proto_init() } @@ -1264,7 +1306,7 @@ func file_types_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_types_proto_rawDesc), len(file_types_proto_rawDesc)), NumEnums: 1, - NumMessages: 15, + NumMessages: 16, NumExtensions: 0, NumServices: 0, }, diff --git a/internal/agent/server.go b/internal/agent/server.go index da826cc26526..c7b5abb6887a 100644 --- a/internal/agent/server.go +++ b/internal/agent/server.go @@ -170,10 +170,11 @@ func (s *server) StreamEvents(in *pb.StreamEventsRequest, out pb.AgentService_St case event := <-events: out.Send(&pb.StreamEventsResponse{ Event: &pb.ContainerEvent{ - ActorId: event.ActorID, - Name: event.Name, - Host: event.Host, - Timestamp: timestamppb.New(event.Time), + ActorId: event.ActorID, + Name: event.Name, + Host: event.Host, + Timestamp: timestamppb.New(event.Time), + ActorAttributes: event.ActorAttributes, }, }) case <-out.Context().Done(): @@ -431,6 +432,12 @@ func (s *server) UpdateNotificationConfig(ctx context.Context, req *pb.UpdateNot URL: d.Url, Template: d.Template, Headers: d.Headers, + APIKey: d.ApiKey, + Prefix: d.Prefix, + } + if d.ExpiresAt != nil { + t := d.ExpiresAt.AsTime() + dispatchers[i].ExpiresAt = &t } } diff --git a/internal/container/types.go b/internal/container/types.go index f4d2c1b8b646..03abd8a180d5 100644 --- a/internal/container/types.go +++ b/internal/container/types.go @@ -36,10 +36,12 @@ func (container Container) ToProto() pb.Container { var pbStats []*pb.ContainerStat for _, stat := range container.Stats.Data() { pbStats = append(pbStats, &pb.ContainerStat{ - Id: stat.ID, - CpuPercent: stat.CPUPercent, - MemoryPercent: stat.MemoryPercent, - MemoryUsage: stat.MemoryUsage, + Id: stat.ID, + CpuPercent: stat.CPUPercent, + MemoryPercent: stat.MemoryPercent, + MemoryUsage: stat.MemoryUsage, + NetworkRxTotal: stat.NetworkRxTotal, + NetworkTxTotal: stat.NetworkTxTotal, }) } @@ -68,10 +70,12 @@ func FromProto(c *pb.Container) Container { var stats []ContainerStat for _, stat := range c.Stats { stats = append(stats, ContainerStat{ - ID: stat.Id, - CPUPercent: stat.CpuPercent, - MemoryPercent: stat.MemoryPercent, - MemoryUsage: stat.MemoryUsage, + ID: stat.Id, + CPUPercent: stat.CpuPercent, + MemoryPercent: stat.MemoryPercent, + MemoryUsage: stat.MemoryUsage, + NetworkRxTotal: stat.NetworkRxTotal, + NetworkTxTotal: stat.NetworkTxTotal, }) } diff --git a/protos/types.proto b/protos/types.proto index 147d9836bbc8..11e6d5d00cf4 100644 --- a/protos/types.proto +++ b/protos/types.proto @@ -70,6 +70,7 @@ message ContainerEvent { string name = 2; string host = 3; google.protobuf.Timestamp timestamp = 4; + map actorAttributes = 5; } message Host { @@ -113,6 +114,9 @@ message NotificationDispatcher { string url = 4; string template = 5; map headers = 6; + string apiKey = 7; + string prefix = 8; + google.protobuf.Timestamp expiresAt = 9; } message NotificationSubscriptionStats {