On this page本页内容
Available only in MongoDB Enterprise and MongoDB Atlas.仅在MongoDB Enterprise和MongoDB Atlas中可用。
The event auditing feature can record events in JSON format. 事件审计功能可以以JSON格式记录事件。To configure auditing output, see Configure Auditing.要配置审核输出,请参阅配置审核。
Changed in version 5.0.在版本5.0中更改。
The recorded JSON messages have the following syntax:记录的JSON消息具有以下语法:
{ atype: <string>, ts : { $date: <timestamp> }, uuid : { $binary: <string>, $type: <string> }, local: { ip: <string>, port: <int> || isSystemUser: <boolean> || unix: <string> }, remote: { ip: <string>, port: <int> || isSystemUser: <boolean> || unix: <string> }, users : [ { user: <string>, db: <string> }, ... ], roles: [ { role: <string>, db: <string> }, ... ], param: <document>, result: <int> }
atype | string | |
ts | document | |
| document |
|
| document |
|
remote | document |
|
users | array | user field for the username and a db field for the authentication database for that user.user 字段和该用户的身份验证数据库的db 字段。
|
roles | array | role field for the name of the role and a db field for the database associated with the role.role 字段和与角色关联的数据库的db 字段。
|
param | document | |
result | integer |
The following table lists for each 下表列出了每个atype
or action type, the associated param
details and the result
values, if any.atype
或操作类型、相关param
详细信息和result
值(如果有)。
atype | param | result |
---|---|---|
| { user: <user name>, db: <database>, mechanism: <mechanism> }
| 0 - 18 - 334 - |
| { command: <name>, ns: <database>.<collection>, args: <command object> } ns args
| 0 - 13 - |
| { localEndpoint : { ip : <IP address of running instance>, port : <port of running instance> } || { unix : <MongoDB socket file path if connecting through a Unix domain socket> }, clientMetadata : { driver : { name : <client driver name>, version : <client driver version> }, os : { type : <client operating system type>, name : <client operating system name>, architecture : <client operating system architecture>, version : <client operating system version> }, platform : <client platform name>, application : { name : <client application name> } } }
| 0 - |
{ ns: <database>.<collection || view>, viewOn: <database>.<collection>, pipeline: [ <pipeline definition> ] }
| 0 - | |
createDatabase | { ns: <database> } | 0 - |
{ ns: <database>.<collection>, indexName: <index name>, indexSpec: <index specification>, indexBuildState: <index build state> }
| 0 - 276 -
| |
| { document: { <collection modifications> }, ns: <database>.<collection>, operation: <database operation> }
| 0 - |
renameCollection | { old: <database>.<collection>, new: <database>.<collection> } | 0 - |
{ ns: <database>.<collection || view>, viewOn: <database>.<collection>, pipeline: [ <pipeline definition> ] }
| 0 - Success26 - NamespaceNotFound
| |
dropDatabase | { ns: <database> } | 0 - |
dropIndex | { ns: <database>.<collection>, indexName: <index name> } | 0 - |
createUser | { user: <user name>, db: <database>, customData: <document>, roles: [ { role: <role name>, db: <database> }, ... ] }
| 0 - |
dropUser | { user: <user name>, db: <database> } | 0 - |
dropAllUsersFromDatabase | { db: <database> } | 0 - |
updateUser | { user: <user name>, db: <database>, passwordChanged: <boolean>, customData: <document>, roles: [ { role: <role name>, db: <database> }, ... ] }
| 0 - |
grantRolesToUser | { user: <user name>, db: <database>, roles: [ { role: <role name>, db: <database> }, ... ] } | 0 - |
revokeRolesFromUser | { user: <user name>, db: <database>, roles: [ { role: <role name>, db: <database> }, ... ] } | 0 - |
createRole | { role: <role name>, db: <database>, roles: [ { role: <role name>, db: <database> }, ... ], privileges: [ { resource: <resource document>, actions: [ <action>, ... ] }, ... ] }
| 0 - |
updateRole | { role: <role name>, db: <database>, roles: [ { role: <role name>, db: <database> }, ... ], privileges: [ { resource: <resource document>, actions: [ <action>, ... ] }, ... ] }
| 0 - |
dropRole | { role: <role name>, db: <database> } | 0 - |
dropAllRolesFromDatabase | { db: <database> } | 0 - |
grantRolesToRole | { role: <role name>, db: <database>, roles: [ { role: <role name>, db: <database> }, ... ] } | 0 - |
revokeRolesFromRole | { role: <role name>, db: <database>, roles: [ { role: <role name>, db: <database> }, ... ] } | 0 - |
grantPrivilegesToRole | { role: <role name>, db: <database>, privileges: [ { resource: <resource document>, actions: [ <action>, ... ] }, ... ] }
| 0 - |
revokePrivilegesFromRole | { role: <role name>, db: <database name>, privileges: [ { resource: <resource document>, actions: [ <action>, ... ] }, ... ] }
| 0 - |
replSetReconfig | { old: { _id: <replicaSetName>, version: <number>, ... members: [ ... ], settings: { ... } }, new: { _id: <replicaSetName>, version: <number>, ... members: [ ... ], settings: { ... } } }
| 0 - |
enableSharding | { ns: <database> } | 0 - |
shardCollection | { ns: <database>.<collection>, key: <shard key pattern>, options: { unique: <boolean> } } | 0 - |
addShard | { shard: <shard name>, connectionString: <hostname>:<port>, maxSize: <maxSize> }
| 0 - |
refineCollectionShardKey | { ns: <database>.<collection>, key: <shard key pattern> } | 0 - |
removeShard | { shard: <shard name> } | 0 - |
shutdown | { }
| 0 - |
applicationMessage | { msg: <custom message string> } | 0 - |
| { reason: <string>, initialUsers: [ <document>, ... ], updatedUsers: [ <document>, ... ], }
| 0 - |
| { options: <document> }
| 0 - |