@@ -28,11 +28,15 @@ var (
28
28
Name : "mongoproxy_plugins_schema_config_hash" ,
29
29
Help : "The current hash of the schema config file loaded" ,
30
30
})
31
-
32
31
schemaDeny = promauto .NewCounterVec (prometheus.CounterOpts {
33
32
Name : "mongoproxy_plugins_schema_deny_total" ,
34
33
Help : "The total deny returns of a command" ,
35
34
}, []string {"db" , "collection" , "command" })
35
+
36
+ schemaDenyLogOnly = promauto .NewCounterVec (prometheus.CounterOpts {
37
+ Name : "mongoproxy_plugins_schema_deny_logonly_total" ,
38
+ Help : "The total deny returns of a command" ,
39
+ }, []string {"collection" , "command" })
36
40
)
37
41
38
42
const (
@@ -132,13 +136,11 @@ func (p *SchemaPlugin) Process(ctx context.Context, r *plugins.Request, next plu
132
136
for _ , document := range cmd .Documents {
133
137
if err := schema .ValidateInsert (ctx , cmd .Database , cmd .Collection , document ); err != nil {
134
138
schemaDeny .WithLabelValues (cmd .Database , cmd .Collection , r .CommandName ).Inc ()
139
+ logrus .Warningf ("ENFORCE SCHEMA ERROR: %s, in db: %s, collection: %s, with cmd: %s" ,
140
+ err .Error (), cmd .Database , cmd .Collection , r .CommandName )
135
141
if ! p .conf .EnforceSchemaLogOnly {
136
- logrus .Errorf ("ENFORCE SCHEMA ERROR: %s, in db: %s, collection: %s, with cmd: %s" ,
137
- err .Error (), cmd .Database , cmd .Collection , r .CommandName )
138
142
return mongoerror .DocumentValidationFailure .ErrMessage (err .Error ()), nil
139
143
}
140
- logrus .Warningf ("ENFORCE SCHEMA LOGONLY: %s, in db: %s, collection: %s, with cmd: %s" ,
141
- err .Error (), cmd .Database , cmd .Collection , r .CommandName )
142
144
}
143
145
}
144
146
@@ -148,13 +150,11 @@ func (p *SchemaPlugin) Process(ctx context.Context, r *plugins.Request, next plu
148
150
logrus .Debugf ("command findAndModify: %s" , cmd .Update )
149
151
if err := schema .ValidateUpdate (ctx , cmd .Database , cmd .Collection , cmd .Update , bsonutil .GetBoolDefault (cmd .Upsert , false )); err != nil {
150
152
schemaDeny .WithLabelValues (cmd .Database , cmd .Collection , r .CommandName ).Inc ()
153
+ logrus .Warningf ("ENFORCE SCHEMA ERROR: %s, in db: %s, collection: %s, with cmd: %s" ,
154
+ err .Error (), cmd .Database , cmd .Collection , r .CommandName )
151
155
if ! p .conf .EnforceSchemaLogOnly {
152
- logrus .Errorf ("ENFORCE SCHEMA ERROR: %s, in db: %s, collection: %s, with cmd: %s" ,
153
- err .Error (), cmd .Database , cmd .Collection , r .CommandName )
154
156
return mongoerror .DocumentValidationFailure .ErrMessage (err .Error ()), nil
155
157
}
156
- logrus .Warningf ("ENFORCE SCHEMA LOGONLY: %s, in db: %s, collection: %s, with cmd: %s" ,
157
- err .Error (), cmd .Database , cmd .Collection , r .CommandName )
158
158
}
159
159
}
160
160
@@ -164,13 +164,11 @@ func (p *SchemaPlugin) Process(ctx context.Context, r *plugins.Request, next plu
164
164
logrus .Debugf ("command Update wiht doc: %v" , updateDoc )
165
165
if err := schema .ValidateUpdate (ctx , cmd .Database , cmd .Collection , updateDoc .U , bsonutil .GetBoolDefault (updateDoc .Upsert , false )); err != nil {
166
166
schemaDeny .WithLabelValues (cmd .Database , cmd .Collection , r .CommandName ).Inc ()
167
+ logrus .Warningf ("ENFORCE SCHEMA ERROR: %s, in db: %s, collection: %s, with cmd: %s" ,
168
+ err .Error (), cmd .Database , cmd .Collection , r .CommandName )
167
169
if ! p .conf .EnforceSchemaLogOnly {
168
- logrus .Errorf ("ENFORCE SCHEMA ERROR: %s, in db: %s, collection: %s, with cmd: %s" ,
169
- err .Error (), cmd .Database , cmd .Collection , r .CommandName )
170
170
return mongoerror .DocumentValidationFailure .ErrMessage (err .Error ()), nil
171
171
}
172
- logrus .Warningf ("ENFORCE SCHEMA LOGONLY: %s, in db: %s, collection: %s, with cmd: %s" ,
173
- err .Error (), cmd .Database , cmd .Collection , r .CommandName )
174
172
}
175
173
}
176
174
}
0 commit comments