Implement target selection, autodiscovery via aggregator, implement listTargets

This commit is contained in:
2026-03-15 05:04:46 +01:00
parent afa65a2b29
commit 7f93466645
16 changed files with 507 additions and 57 deletions

View File

@@ -709,6 +709,138 @@ func (x *Snapshot) GetEntries() []*TopNEntry {
return nil
}
type ListTargetsRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListTargetsRequest) Reset() {
*x = ListTargetsRequest{}
mi := &file_logtail_proto_msgTypes[9]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListTargetsRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTargetsRequest) ProtoMessage() {}
func (x *ListTargetsRequest) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[9]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTargetsRequest.ProtoReflect.Descriptor instead.
func (*ListTargetsRequest) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{9}
}
type TargetInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // display name (the --source value of the collector)
Addr string `protobuf:"bytes,2,opt,name=addr,proto3" json:"addr,omitempty"` // gRPC address to use as target=; empty means "this endpoint"
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *TargetInfo) Reset() {
*x = TargetInfo{}
mi := &file_logtail_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *TargetInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*TargetInfo) ProtoMessage() {}
func (x *TargetInfo) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[10]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use TargetInfo.ProtoReflect.Descriptor instead.
func (*TargetInfo) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{10}
}
func (x *TargetInfo) GetName() string {
if x != nil {
return x.Name
}
return ""
}
func (x *TargetInfo) GetAddr() string {
if x != nil {
return x.Addr
}
return ""
}
type ListTargetsResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Targets []*TargetInfo `protobuf:"bytes,1,rep,name=targets,proto3" json:"targets,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *ListTargetsResponse) Reset() {
*x = ListTargetsResponse{}
mi := &file_logtail_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *ListTargetsResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ListTargetsResponse) ProtoMessage() {}
func (x *ListTargetsResponse) ProtoReflect() protoreflect.Message {
mi := &file_logtail_proto_msgTypes[11]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ListTargetsResponse.ProtoReflect.Descriptor instead.
func (*ListTargetsResponse) Descriptor() ([]byte, []int) {
return file_logtail_proto_rawDescGZIP(), []int{11}
}
func (x *ListTargetsResponse) GetTargets() []*TargetInfo {
if x != nil {
return x.Targets
}
return nil
}
var File_logtail_proto protoreflect.FileDescriptor
const file_logtail_proto_rawDesc = "" +
@@ -755,7 +887,14 @@ const file_logtail_proto_rawDesc = "" +
"\bSnapshot\x12\x16\n" +
"\x06source\x18\x01 \x01(\tR\x06source\x12\x1c\n" +
"\ttimestamp\x18\x02 \x01(\x03R\ttimestamp\x12,\n" +
"\aentries\x18\x03 \x03(\v2\x12.logtail.TopNEntryR\aentries*:\n" +
"\aentries\x18\x03 \x03(\v2\x12.logtail.TopNEntryR\aentries\"\x14\n" +
"\x12ListTargetsRequest\"4\n" +
"\n" +
"TargetInfo\x12\x12\n" +
"\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" +
"\x04addr\x18\x02 \x01(\tR\x04addr\"D\n" +
"\x13ListTargetsResponse\x12-\n" +
"\atargets\x18\x01 \x03(\v2\x13.logtail.TargetInfoR\atargets*:\n" +
"\bStatusOp\x12\x06\n" +
"\x02EQ\x10\x00\x12\x06\n" +
"\x02NE\x10\x01\x12\x06\n" +
@@ -774,11 +913,12 @@ const file_logtail_proto_rawDesc = "" +
"\x04W15M\x10\x02\x12\b\n" +
"\x04W60M\x10\x03\x12\a\n" +
"\x03W6H\x10\x04\x12\b\n" +
"\x04W24H\x10\x052\xbf\x01\n" +
"\x04W24H\x10\x052\x89\x02\n" +
"\x0eLogtailService\x123\n" +
"\x04TopN\x12\x14.logtail.TopNRequest\x1a\x15.logtail.TopNResponse\x126\n" +
"\x05Trend\x12\x15.logtail.TrendRequest\x1a\x16.logtail.TrendResponse\x12@\n" +
"\x0fStreamSnapshots\x12\x18.logtail.SnapshotRequest\x1a\x11.logtail.Snapshot0\x01B0Z.git.ipng.ch/ipng/nginx-logtail/proto/logtailpbb\x06proto3"
"\x0fStreamSnapshots\x12\x18.logtail.SnapshotRequest\x1a\x11.logtail.Snapshot0\x01\x12H\n" +
"\vListTargets\x12\x1b.logtail.ListTargetsRequest\x1a\x1c.logtail.ListTargetsResponseB0Z.git.ipng.ch/ipng/nginx-logtail/proto/logtailpbb\x06proto3"
var (
file_logtail_proto_rawDescOnce sync.Once
@@ -793,20 +933,23 @@ func file_logtail_proto_rawDescGZIP() []byte {
}
var file_logtail_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
var file_logtail_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
var file_logtail_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_logtail_proto_goTypes = []any{
(StatusOp)(0), // 0: logtail.StatusOp
(GroupBy)(0), // 1: logtail.GroupBy
(Window)(0), // 2: logtail.Window
(*Filter)(nil), // 3: logtail.Filter
(*TopNRequest)(nil), // 4: logtail.TopNRequest
(*TopNEntry)(nil), // 5: logtail.TopNEntry
(*TopNResponse)(nil), // 6: logtail.TopNResponse
(*TrendRequest)(nil), // 7: logtail.TrendRequest
(*TrendPoint)(nil), // 8: logtail.TrendPoint
(*TrendResponse)(nil), // 9: logtail.TrendResponse
(*SnapshotRequest)(nil), // 10: logtail.SnapshotRequest
(*Snapshot)(nil), // 11: logtail.Snapshot
(StatusOp)(0), // 0: logtail.StatusOp
(GroupBy)(0), // 1: logtail.GroupBy
(Window)(0), // 2: logtail.Window
(*Filter)(nil), // 3: logtail.Filter
(*TopNRequest)(nil), // 4: logtail.TopNRequest
(*TopNEntry)(nil), // 5: logtail.TopNEntry
(*TopNResponse)(nil), // 6: logtail.TopNResponse
(*TrendRequest)(nil), // 7: logtail.TrendRequest
(*TrendPoint)(nil), // 8: logtail.TrendPoint
(*TrendResponse)(nil), // 9: logtail.TrendResponse
(*SnapshotRequest)(nil), // 10: logtail.SnapshotRequest
(*Snapshot)(nil), // 11: logtail.Snapshot
(*ListTargetsRequest)(nil), // 12: logtail.ListTargetsRequest
(*TargetInfo)(nil), // 13: logtail.TargetInfo
(*ListTargetsResponse)(nil), // 14: logtail.ListTargetsResponse
}
var file_logtail_proto_depIdxs = []int32{
0, // 0: logtail.Filter.status_op:type_name -> logtail.StatusOp
@@ -818,17 +961,20 @@ var file_logtail_proto_depIdxs = []int32{
2, // 6: logtail.TrendRequest.window:type_name -> logtail.Window
8, // 7: logtail.TrendResponse.points:type_name -> logtail.TrendPoint
5, // 8: logtail.Snapshot.entries:type_name -> logtail.TopNEntry
4, // 9: logtail.LogtailService.TopN:input_type -> logtail.TopNRequest
7, // 10: logtail.LogtailService.Trend:input_type -> logtail.TrendRequest
10, // 11: logtail.LogtailService.StreamSnapshots:input_type -> logtail.SnapshotRequest
6, // 12: logtail.LogtailService.TopN:output_type -> logtail.TopNResponse
9, // 13: logtail.LogtailService.Trend:output_type -> logtail.TrendResponse
11, // 14: logtail.LogtailService.StreamSnapshots:output_type -> logtail.Snapshot
12, // [12:15] is the sub-list for method output_type
9, // [9:12] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
13, // 9: logtail.ListTargetsResponse.targets:type_name -> logtail.TargetInfo
4, // 10: logtail.LogtailService.TopN:input_type -> logtail.TopNRequest
7, // 11: logtail.LogtailService.Trend:input_type -> logtail.TrendRequest
10, // 12: logtail.LogtailService.StreamSnapshots:input_type -> logtail.SnapshotRequest
12, // 13: logtail.LogtailService.ListTargets:input_type -> logtail.ListTargetsRequest
6, // 14: logtail.LogtailService.TopN:output_type -> logtail.TopNResponse
9, // 15: logtail.LogtailService.Trend:output_type -> logtail.TrendResponse
11, // 16: logtail.LogtailService.StreamSnapshots:output_type -> logtail.Snapshot
14, // 17: logtail.LogtailService.ListTargets:output_type -> logtail.ListTargetsResponse
14, // [14:18] is the sub-list for method output_type
10, // [10:14] is the sub-list for method input_type
10, // [10:10] is the sub-list for extension type_name
10, // [10:10] is the sub-list for extension extendee
0, // [0:10] is the sub-list for field type_name
}
func init() { file_logtail_proto_init() }
@@ -843,7 +989,7 @@ func file_logtail_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_logtail_proto_rawDesc), len(file_logtail_proto_rawDesc)),
NumEnums: 3,
NumMessages: 9,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},

View File

@@ -22,6 +22,7 @@ const (
LogtailService_TopN_FullMethodName = "/logtail.LogtailService/TopN"
LogtailService_Trend_FullMethodName = "/logtail.LogtailService/Trend"
LogtailService_StreamSnapshots_FullMethodName = "/logtail.LogtailService/StreamSnapshots"
LogtailService_ListTargets_FullMethodName = "/logtail.LogtailService/ListTargets"
)
// LogtailServiceClient is the client API for LogtailService service.
@@ -31,6 +32,7 @@ type LogtailServiceClient interface {
TopN(ctx context.Context, in *TopNRequest, opts ...grpc.CallOption) (*TopNResponse, error)
Trend(ctx context.Context, in *TrendRequest, opts ...grpc.CallOption) (*TrendResponse, error)
StreamSnapshots(ctx context.Context, in *SnapshotRequest, opts ...grpc.CallOption) (grpc.ServerStreamingClient[Snapshot], error)
ListTargets(ctx context.Context, in *ListTargetsRequest, opts ...grpc.CallOption) (*ListTargetsResponse, error)
}
type logtailServiceClient struct {
@@ -80,6 +82,16 @@ func (c *logtailServiceClient) StreamSnapshots(ctx context.Context, in *Snapshot
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type LogtailService_StreamSnapshotsClient = grpc.ServerStreamingClient[Snapshot]
func (c *logtailServiceClient) ListTargets(ctx context.Context, in *ListTargetsRequest, opts ...grpc.CallOption) (*ListTargetsResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(ListTargetsResponse)
err := c.cc.Invoke(ctx, LogtailService_ListTargets_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// LogtailServiceServer is the server API for LogtailService service.
// All implementations must embed UnimplementedLogtailServiceServer
// for forward compatibility.
@@ -87,6 +99,7 @@ type LogtailServiceServer interface {
TopN(context.Context, *TopNRequest) (*TopNResponse, error)
Trend(context.Context, *TrendRequest) (*TrendResponse, error)
StreamSnapshots(*SnapshotRequest, grpc.ServerStreamingServer[Snapshot]) error
ListTargets(context.Context, *ListTargetsRequest) (*ListTargetsResponse, error)
mustEmbedUnimplementedLogtailServiceServer()
}
@@ -106,6 +119,9 @@ func (UnimplementedLogtailServiceServer) Trend(context.Context, *TrendRequest) (
func (UnimplementedLogtailServiceServer) StreamSnapshots(*SnapshotRequest, grpc.ServerStreamingServer[Snapshot]) error {
return status.Error(codes.Unimplemented, "method StreamSnapshots not implemented")
}
func (UnimplementedLogtailServiceServer) ListTargets(context.Context, *ListTargetsRequest) (*ListTargetsResponse, error) {
return nil, status.Error(codes.Unimplemented, "method ListTargets not implemented")
}
func (UnimplementedLogtailServiceServer) mustEmbedUnimplementedLogtailServiceServer() {}
func (UnimplementedLogtailServiceServer) testEmbeddedByValue() {}
@@ -174,6 +190,24 @@ func _LogtailService_StreamSnapshots_Handler(srv interface{}, stream grpc.Server
// This type alias is provided for backwards compatibility with existing code that references the prior non-generic stream type by name.
type LogtailService_StreamSnapshotsServer = grpc.ServerStreamingServer[Snapshot]
func _LogtailService_ListTargets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(ListTargetsRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(LogtailServiceServer).ListTargets(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: LogtailService_ListTargets_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(LogtailServiceServer).ListTargets(ctx, req.(*ListTargetsRequest))
}
return interceptor(ctx, in, info, handler)
}
// LogtailService_ServiceDesc is the grpc.ServiceDesc for LogtailService service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -189,6 +223,10 @@ var LogtailService_ServiceDesc = grpc.ServiceDesc{
MethodName: "Trend",
Handler: _LogtailService_Trend_Handler,
},
{
MethodName: "ListTargets",
Handler: _LogtailService_ListTargets_Handler,
},
},
Streams: []grpc.StreamDesc{
{