mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
enhance: [2.4] add hit segment num metrics for queryHook (#35619)
issue: #35576 pr: #35577 Signed-off-by: chasingegg <chao.gao@zilliz.com>
This commit is contained in:
parent
5b5119a51f
commit
1687d64c46
@ -11,6 +11,7 @@ import (
|
||||
"github.com/milvus-io/milvus/internal/proto/querypb"
|
||||
"github.com/milvus-io/milvus/pkg/common"
|
||||
"github.com/milvus-io/milvus/pkg/log"
|
||||
"github.com/milvus-io/milvus/pkg/metrics"
|
||||
"github.com/milvus-io/milvus/pkg/util/merr"
|
||||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
)
|
||||
@ -29,7 +30,8 @@ func OptimizeSearchParams(ctx context.Context, req *querypb.SearchRequest, query
|
||||
return req, nil
|
||||
}
|
||||
|
||||
log := log.Ctx(ctx).With(zap.Int64("collection", req.GetReq().GetCollectionID()))
|
||||
collectionId := req.GetReq().GetCollectionID()
|
||||
log := log.Ctx(ctx).With(zap.Int64("collection", collectionId))
|
||||
|
||||
serializedPlan := req.GetReq().GetSerializedExprPlan()
|
||||
// plan not found
|
||||
@ -55,6 +57,8 @@ func OptimizeSearchParams(ctx context.Context, req *querypb.SearchRequest, query
|
||||
case *planpb.PlanNode_VectorAnns:
|
||||
// use shardNum * segments num in shard to estimate total segment number
|
||||
estSegmentNum := numSegments * int(channelNum)
|
||||
metrics.QueryNodeSearchHitSegmentNum.WithLabelValues(fmt.Sprint(paramtable.GetNodeID()), fmt.Sprint(collectionId), metrics.SearchLabel).Observe(float64(estSegmentNum))
|
||||
|
||||
withFilter := (plan.GetVectorAnns().GetPredicates() != nil)
|
||||
queryInfo := plan.GetVectorAnns().GetQueryInfo()
|
||||
params := map[string]any{
|
||||
|
@ -362,6 +362,18 @@ var (
|
||||
nodeIDLabelName,
|
||||
})
|
||||
|
||||
QueryNodeSearchHitSegmentNum = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: milvusNamespace,
|
||||
Subsystem: typeutil.QueryNodeRole,
|
||||
Name: "search_hit_segment_num",
|
||||
Help: "the number of segments actually involved in search task",
|
||||
}, []string{
|
||||
nodeIDLabelName,
|
||||
collectionIDLabelName,
|
||||
queryTypeLabelName,
|
||||
})
|
||||
|
||||
QueryNodeSegmentPruneRatio = prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: milvusNamespace,
|
||||
@ -819,6 +831,7 @@ func RegisterQueryNode(registry *prometheus.Registry) {
|
||||
registry.MustRegister(QueryNodeApplyBFCost)
|
||||
registry.MustRegister(QueryNodeForwardDeleteCost)
|
||||
registry.MustRegister(QueryNodeSegmentPruneRatio)
|
||||
registry.MustRegister(QueryNodeSearchHitSegmentNum)
|
||||
// Add cgo metrics
|
||||
RegisterCGOMetrics(registry)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user