Skip to content
Draft

test #33

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
7 changes: 7 additions & 0 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 @@ -534,12 +538,15 @@ func (p *AuthzPlugin) Process(ctx context.Context, r *plugins.Request, next plug

var identitiesStrings [][]string
// Handle all log rules
log.Println("Test...")
for _, result := range authorizeResults {
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()}
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{
Expand Down