Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions pkg/mongoproxy/plugins/authz/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ var (
Name: "mongoproxy_plugins_authz_deny_total",
Help: "The total deny returns of a command",
}, []string{"db", "collection", "command"})
authzLogOnly = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "mongoproxy_plugins_authz_logonly_total",
Help: "The total num of cmd that hit log only policy",
}, []string{"type", "user", "policy", "effect", "method", "resource", "command", "db", "collection"})

OPEN_COMMAND = map[string]struct{}{
"isMaster": {},
Expand Down Expand Up @@ -538,9 +542,11 @@ func (p *AuthzPlugin) Process(ctx context.Context, r *plugins.Request, next plug
for _, logRule := range result.LogOnlyRules {
if identitiesStrings == nil {
identitiesStrings = make([][]string, len(identities))
for i, id := range identities {
identitiesStrings[i] = []string{id.Type(), id.User()}
}
}
for i, id := range identities {
identitiesStrings[i] = []string{id.Type(), id.User()}
log.Println("Hitting metric mongoproxy_plugins_authz_logonly_total...")
authzLogOnly.WithLabelValues(id.Type(), id.User(), logRule.PolicyName, logRule.Effect.String(), result.AuthorizationMethod.String(), result.Resource.String(), r.CommandName, command.GetCommandDatabase(r.Command), command.GetCommandCollection(r.Command)).Inc()
}
logrus.NewEntry(logrus.StandardLogger()).WithFields(logrus.Fields{
"identities": identitiesStrings,
Expand Down