- Reference >
- Database Commands >
- Administration Commands >
- getAuditConfig
getAuditConfig¶
On this page
Definition¶
-
getAuditConfig¶ New in version 5.0.
getAuditConfigis an administrative command that retrieves audit configurations frommongodandmongosserver instances.Use the
db.adminCommand( { command } )method to rungetAuditConfigagainst theadmindatabase.
Behavior¶
Auditing must be enabled in order to use
getAuditConfig.
Nodes that are not participating in a runtime audit configuration
return their current configuration file settings for
auditLog.filter and setParameter.auditAuthorizationSuccess.
Nodes that are participating in the runtime audit synthesize their
current configuration from memory. Configuration updates are
distributed via the oplog mechanism which means updates on
mongod nodes are distributed to secondary nodes very
quickly. However, the distribution mechanism is different on
mongos nodes. mongos nodes have to
poll the primary server
at regular intervals for configuration updates. You may see stale data
due to polling delay if you run setAuditConfig on the
primary server and getAuditConfig on a
shard before the shard has polled the primary server
for updated configuration details.
Note
If you are writing automated audit scripts, note that the quoting
style and the types used to represent the cluster signature differ
between mongosh and the legacy mongo shell. In mongosh
the types are Binary and Long. The corresponding types in the legacy
shell are BinData and NumberLong.
Examples¶
Run getAuditConfig on the admin database .
The example server is configured to audit read and write operations. It
has a filter which captures the desired operations and the
auditAuthorizationSuccess value has been set to true.
See also