mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
Add the user rpc counter (#22872)
Signed-off-by: SimFG <bang.fu@zilliz.com>
This commit is contained in:
parent
28f8dc89e5
commit
8259ca6929
@ -232,6 +232,14 @@ var (
|
||||
Name: "hook_func_count",
|
||||
Help: "the hook function count",
|
||||
}, []string{functionLabelName, fullMethodLabelName})
|
||||
|
||||
UserRPCCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: milvusNamespace,
|
||||
Subsystem: typeutil.ProxyRole,
|
||||
Name: "user_rpc_count",
|
||||
Help: "the rpc count of a user",
|
||||
}, []string{usernameLabelName})
|
||||
)
|
||||
|
||||
// RegisterProxy registers Proxy metrics
|
||||
@ -267,6 +275,7 @@ func RegisterProxy(registry *prometheus.Registry) {
|
||||
|
||||
registry.MustRegister(ProxyLimiterRate)
|
||||
registry.MustRegister(ProxyHookFunc)
|
||||
registry.MustRegister(UserRPCCounter)
|
||||
}
|
||||
|
||||
// SetRateGaugeByRateType sets ProxyLimiterRate metrics.
|
||||
|
@ -4,11 +4,10 @@ import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/metrics"
|
||||
"github.com/milvus-io/milvus/internal/util"
|
||||
|
||||
"github.com/milvus-io/milvus/internal/util/crypto"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
// validAuth validates the authentication
|
||||
@ -27,8 +26,11 @@ func validAuth(ctx context.Context, authorization []string) bool {
|
||||
secrets := strings.SplitN(rawToken, util.CredentialSeperator, 2)
|
||||
username := secrets[0]
|
||||
password := secrets[1]
|
||||
|
||||
return passwordVerify(ctx, username, password, globalMetaCache)
|
||||
isSuccess := passwordVerify(ctx, username, password, globalMetaCache)
|
||||
if isSuccess {
|
||||
metrics.UserRPCCounter.WithLabelValues(username).Inc()
|
||||
}
|
||||
return isSuccess
|
||||
}
|
||||
|
||||
func validSourceID(ctx context.Context, authorization []string) bool {
|
||||
|
Loading…
Reference in New Issue
Block a user