From fcd23e2ec2f64a6478ccb9023a529541fa4d8c5c Mon Sep 17 00:00:00 2001 From: smellthemoon <64083300+smellthemoon@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:44:47 +0800 Subject: [PATCH] enhance:Add upsert vector metrics(#29226) (#29674) pr: https://github.com/milvus-io/milvus/pull/29226 Signed-off-by: lixinguo Co-authored-by: lixinguo --- internal/proxy/impl.go | 5 +++++ pkg/metrics/proxy_metrics.go | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 36636ea245..39d208d132 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -2480,10 +2480,15 @@ func (node *Proxy) Upsert(ctx context.Context, request *milvuspb.UpsertRequest) setErrorIndex() } + // UpsertCnt always equals to the number of entities in the request + it.result.UpsertCnt = int64(request.NumRows) + rateCol.Add(internalpb.RateType_DMLUpsert.String(), float64(it.upsertMsg.DeleteMsg.Size()+it.upsertMsg.DeleteMsg.Size())) metrics.ProxyFunctionCall.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), method, metrics.SuccessLabel).Inc() + successCnt := it.result.UpsertCnt - int64(len(it.result.ErrIndex)) + metrics.ProxyUpsertVectors.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10)).Add(float64(successCnt)) metrics.ProxyMutationLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.UpsertLabel).Observe(float64(tr.ElapseSpan().Milliseconds())) metrics.ProxyCollectionMutationLatency.WithLabelValues(strconv.FormatInt(paramtable.GetNodeID(), 10), metrics.UpsertLabel, request.CollectionName).Observe(float64(tr.ElapseSpan().Milliseconds())) diff --git a/pkg/metrics/proxy_metrics.go b/pkg/metrics/proxy_metrics.go index 3b45aaf43f..9e82173f9a 100644 --- a/pkg/metrics/proxy_metrics.go +++ b/pkg/metrics/proxy_metrics.go @@ -51,6 +51,15 @@ var ( Help: "counter of vectors successfully inserted", }, []string{nodeIDLabelName}) + // ProxyUpsertVectors record the number of vectors upsert successfully. + ProxyUpsertVectors = prometheus.NewCounterVec( + prometheus.CounterOpts{ + Namespace: milvusNamespace, + Subsystem: typeutil.ProxyRole, + Name: "upsert_vectors_count", + Help: "counter of vectors successfully upserted", + }, []string{nodeIDLabelName}) + // ProxySQLatency record the latency of search successfully. ProxySQLatency = prometheus.NewHistogramVec( prometheus.HistogramOpts{ @@ -295,6 +304,7 @@ func RegisterProxy(registry *prometheus.Registry) { registry.MustRegister(ProxyReceivedNQ) registry.MustRegister(ProxySearchVectors) registry.MustRegister(ProxyInsertVectors) + registry.MustRegister(ProxyUpsertVectors) registry.MustRegister(ProxySQLatency) registry.MustRegister(ProxyCollectionSQLatency)