File tree Expand file tree Collapse file tree 5 files changed +65
-1
lines changed
internal/proxy/accesslog/info Expand file tree Collapse file tree 5 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,10 @@ proxy:
303
303
format : " [$time_now] [ACCESS] <$user_name: $user_addr> $method_name [status: $method_status] [code: $error_code] [sdk: $sdk_version] [msg: $error_msg] [traceID: $trace_id] [timeCost: $time_cost]"
304
304
query :
305
305
format : " [$time_now] [ACCESS] <$user_name: $user_addr> $method_name [status: $method_status] [code: $error_code] [sdk: $sdk_version] [msg: $error_msg] [traceID: $trace_id] [timeCost: $time_cost] [database: $database_name] [collection: $collection_name] [partitions: $partition_name] [expr: $method_expr]"
306
- methods : " Query,Search,Delete"
306
+ methods : " Query, Delete"
307
+ search :
308
+ format : " [$time_now] [ACCESS] <$user_name: $user_addr> $method_name [status: $method_status] [code: $error_code] [sdk: $sdk_version] [msg: $error_msg] [traceID: $trace_id] [timeCost: $time_cost] [database: $database_name] [collection: $collection_name] [partitions: $partition_name] [anns_field: $anns_field] [expr: $method_expr]"
309
+ methods : " HybridSearch, Search"
307
310
cacheSize : 0 # Size of log of write cache, in byte. (Close write cache if size was 0)
308
311
cacheFlushInterval : 3 # time interval of auto flush write cache, in seconds. (Close auto flush if interval was 0)
309
312
connectionCheckIntervalSeconds : 120 # the interval time(in seconds) for connection manager to scan inactive client info
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import (
23
23
"strings"
24
24
"time"
25
25
26
+ "github.com/samber/lo"
26
27
"go.opentelemetry.io/otel/trace"
27
28
"google.golang.org/grpc"
28
29
"google.golang.org/grpc/codes"
@@ -264,6 +265,10 @@ func (i *GrpcAccessInfo) Expression() string {
264
265
return expr .(string )
265
266
}
266
267
268
+ if req , ok := i .req .(* milvuspb.HybridSearchRequest ); ok {
269
+ return listToString (lo .Map (req .GetRequests (), func (req * milvuspb.SearchRequest , _ int ) string { return req .GetDsl () }))
270
+ }
271
+
267
272
dsl , ok := requestutil .GetDSLFromRequest (i .req )
268
273
if ok {
269
274
return dsl .(string )
@@ -299,3 +304,15 @@ func (i *GrpcAccessInfo) ConsistencyLevel() string {
299
304
}
300
305
return Unknown
301
306
}
307
+
308
+ func (i * GrpcAccessInfo ) AnnsField () string {
309
+ if req , ok := i .req .(* milvuspb.SearchRequest ); ok {
310
+ return getAnnsFieldFromKvs (req .GetSearchParams ())
311
+ }
312
+
313
+ if req , ok := i .req .(* milvuspb.HybridSearchRequest ); ok {
314
+ fields := lo .Map (req .GetRequests (), func (req * milvuspb.SearchRequest , _ int ) string { return getAnnsFieldFromKvs (req .GetSearchParams ()) })
315
+ return listToString (fields )
316
+ }
317
+ return Unknown
318
+ }
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ var MetricFuncMap = map[string]getMetricFunc{
47
47
"$sdk_version" : getSdkVersion ,
48
48
"$cluster_prefix" : getClusterPrefix ,
49
49
"$consistency_level" : getConsistencyLevel ,
50
+ "$anns_field" : getAnnsField ,
50
51
}
51
52
52
53
type AccessInfo interface {
@@ -64,6 +65,7 @@ type AccessInfo interface {
64
65
ErrorMsg () string
65
66
ErrorType () string
66
67
DbName () string
68
+ AnnsField () string
67
69
CollectionName () string
68
70
PartitionName () string
69
71
Expression () string
@@ -165,6 +167,10 @@ func getConsistencyLevel(i AccessInfo) string {
165
167
return i .ConsistencyLevel ()
166
168
}
167
169
170
+ func getAnnsField (i AccessInfo ) string {
171
+ return i .AnnsField ()
172
+ }
173
+
168
174
func getClusterPrefix (i AccessInfo ) string {
169
175
return ClusterPrefix .Load ()
170
176
}
Original file line number Diff line number Diff line change @@ -23,7 +23,9 @@ import (
23
23
"time"
24
24
25
25
"github.com/gin-gonic/gin"
26
+ "github.com/samber/lo"
26
27
28
+ "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
27
29
"github.com/milvus-io/milvus/pkg/v2/util/requestutil"
28
30
)
29
31
@@ -187,6 +189,10 @@ func (i *RestfulInfo) Expression() string {
187
189
return expr .(string )
188
190
}
189
191
192
+ if req , ok := i .req .(* milvuspb.HybridSearchRequest ); ok {
193
+ return listToString (lo .Map (req .GetRequests (), func (req * milvuspb.SearchRequest , _ int ) string { return req .GetDsl () }))
194
+ }
195
+
190
196
dsl , ok := requestutil .GetDSLFromRequest (i .req )
191
197
if ok {
192
198
return dsl .(string )
@@ -209,3 +215,14 @@ func (i *RestfulInfo) ConsistencyLevel() string {
209
215
}
210
216
return Unknown
211
217
}
218
+
219
+ func (i * RestfulInfo ) AnnsField () string {
220
+ if req , ok := i .req .(* milvuspb.SearchRequest ); ok {
221
+ return getAnnsFieldFromKvs (req .GetSearchParams ())
222
+ }
223
+
224
+ if req , ok := i .req .(* milvuspb.HybridSearchRequest ); ok {
225
+ return listToString (lo .Map (req .GetRequests (), func (req * milvuspb.SearchRequest , _ int ) string { return getAnnsFieldFromKvs (req .GetSearchParams ()) }))
226
+ }
227
+ return Unknown
228
+ }
Original file line number Diff line number Diff line change @@ -25,8 +25,10 @@ import (
25
25
"go.uber.org/atomic"
26
26
"google.golang.org/grpc/metadata"
27
27
28
+ "github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
28
29
"github.com/milvus-io/milvus/pkg/v2/util"
29
30
"github.com/milvus-io/milvus/pkg/v2/util/crypto"
31
+ "github.com/milvus-io/milvus/pkg/v2/util/funcutil"
30
32
)
31
33
32
34
var ClusterPrefix atomic.String
@@ -90,3 +92,22 @@ func getSdkTypeByUserAgent(userAgents []string) (string, bool) {
90
92
return "" , false
91
93
}
92
94
}
95
+
96
+ func getAnnsFieldFromKvs (kvs []* commonpb.KeyValuePair ) string {
97
+ field , err := funcutil .GetAttrByKeyFromRepeatedKV ("anns_field" , kvs )
98
+ if err != nil {
99
+ return "default"
100
+ }
101
+ return field
102
+ }
103
+
104
+ func listToString (strs []string ) string {
105
+ result := "["
106
+ for i , str := range strs {
107
+ if i != 0 {
108
+ result += ", "
109
+ }
110
+ result += "\" " + str + "\" "
111
+ }
112
+ return result + "]"
113
+ }
You can’t perform that action at this time.
0 commit comments