Skip to content

Commit 5b66594

Browse files
mungitoperritojeff-allen-mongo
authored andcommitted
DOCSP-16015 add getAuditConfig and API
1 parent 5079a9d commit 5b66594

File tree

7 files changed

+381
-171
lines changed

7 files changed

+381
-171
lines changed
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
==============
2+
getAuditConfig
3+
==============
4+
5+
.. default-domain:: mongodb
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
Definition
14+
----------
15+
16+
.. dbcommand:: getAuditConfig
17+
18+
.. versionadded:: 5.0
19+
20+
:dbcommand:`getAuditConfig` is an administrative command that
21+
retrieves audit configurations from :binary:`~bin.mongod` and
22+
:binary:`~bin.mongos` server instances.
23+
24+
Use the
25+
:method:`db.adminCommand( { command } )<db.adminCommand()>` method
26+
to run :dbcommand:`getAuditConfig` against the ``admin`` database.
27+
28+
.. code-block:: javascript
29+
30+
db.adminCommand( { getAuditConfig: 1 } )
31+
32+
Behavior
33+
--------
34+
35+
:doc:`Auditing </core/auditing>` must be enabled in order to use
36+
:dbcommand:`getAuditConfig`.
37+
38+
Nodes that are not participating in a runtime audit configuration
39+
return their current configuration file settings for
40+
``auditLog.filter`` and ``setParameter.auditAuthorizationSuccess``.
41+
42+
Nodes that are participating in the runtime audit synthesize their
43+
current configuration from memory. Configuration updates are
44+
distributed via the :term:`oplog` mechanism which means updates on
45+
:binary:`~bin.mongod` nodes are distributed to secondary nodes very
46+
quickly. However, the distribution mechanism is different on
47+
:binary:`~bin.mongos` nodes. :binary:`~bin.mongos` nodes have to
48+
:parameter:`poll <auditConfigPollingFrequencySecs>` the primary server
49+
at regular intervals for configuration updates. You may see stale data
50+
due to polling delay if you run ``setAuditConfig`` on the primary
51+
server and :dbcommand:`getAuditConfig` on a :doc:`shard </sharding>`
52+
before the shard has polled the primary server for updated
53+
configuration details.
54+
55+
.. note::
56+
57+
If you are writing automated audit scripts, note that the quoting
58+
style and the types used to represent the cluster signature differ
59+
between ``mongosh`` and the legacy ``mongo`` shell. In ``mongosh``
60+
the types are Binary and Long. The corresponding types in the legacy
61+
shell are BinData and NumberLong.
62+
63+
.. code-block:: javascript
64+
:copyable: false
65+
66+
// mongosh
67+
signature: {
68+
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
69+
keyId: Long("0")
70+
}
71+
72+
// mongo
73+
"signature" : {
74+
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
75+
"keyId" : NumberLong(0)
76+
}
77+
78+
Examples
79+
--------
80+
81+
Run :dbcommand:`getAuditConfig` on the ``admin`` database .
82+
83+
.. code-block:: javascript
84+
85+
db.adminCommand({getAuditConfig: 1})
86+
87+
The example server is configured to audit read and write operations. It
88+
has a filter which captures the desired operations and the
89+
``auditAuthorizationSuccess`` value has been set to ``true``.
90+
91+
.. code-block:: javascript
92+
:copyable: false
93+
:emphasize-lines: 3-7, 9
94+
95+
{
96+
generation: ObjectId("60e73e74680a655705f16525"),
97+
filter: {
98+
atype: 'authCheck',
99+
'param.command': {
100+
'$in': [ 'find', 'insert', 'delete', 'update', 'findandmodify' ]
101+
}
102+
},
103+
auditAuthorizationSuccess: true,
104+
ok: 1,
105+
'$clusterTime': {
106+
clusterTime: Timestamp(1, 1625767540),
107+
signature: {
108+
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
109+
keyId: Long("0")
110+
}
111+
},
112+
operationTime: Timestamp(1, 1625767540)
113+
}
114+
115+
.. seealso::
116+
117+
:method:`db.adminCommand`, :doc:`configure audit filters</tutorial/configure-audit-filters>`
118+

source/reference/command/nav-administration.txt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,18 @@ Administration Commands
8181
- Unlocks one fsync lock.
8282

8383
* - :dbcommand:`getDefaultRWConcern`
84-
85-
- Retrieves the global default read and write concern options
84+
85+
- Retrieves the global default read and write concern options
8686
for the deployment.
8787

8888
.. versionadded:: 4.4
8989

90+
* - :dbcommand:`getAuditConfig`
91+
92+
- Retrieves details on audit configuration and filters.
93+
94+
.. versionadded:: 5.0
95+
9096
* - :dbcommand:`getParameter`
9197

9298
- Retrieves configuration options.
@@ -145,8 +151,8 @@ Administration Commands
145151

146152
* - :dbcommand:`setDefaultRWConcern`
147153

148-
- Sets the global default read and write concern options for the
149-
deployment.
154+
- Sets the global default read and write concern options for the
155+
deployment.
150156

151157
.. versionadded:: 4.4
152158

@@ -156,8 +162,8 @@ Administration Commands
156162

157163

158164
.. toctree::
159-
:titlesonly:
160-
:hidden:
165+
:titlesonly:
166+
:hidden:
161167

162168
/reference/command/cloneCollectionAsCapped
163169
/reference/command/collMod
@@ -174,6 +180,7 @@ Administration Commands
174180
/reference/command/filemd5
175181
/reference/command/fsync
176182
/reference/command/fsyncUnlock
183+
/reference/command/getAuditConfig
177184
/reference/command/getDefaultRWConcern
178185
/reference/command/getParameter
179186
/reference/command/killCursors

source/reference/configuration-options.txt

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4322,6 +4322,32 @@ LDAP Parameters
43224322
.. include:: /includes/note-audit-in-enterprise-only.rst
43234323

43244324

4325+
.. setting:: auditLog.filter
4326+
4327+
*Type*: string representation of a document
4328+
4329+
The filter to limit the :ref:`types of operations
4330+
<audit-action-details-results>` the :doc:`audit system
4331+
</core/auditing>` records. The option takes a string representation
4332+
of a query document of the form:
4333+
4334+
.. code-block:: javascript
4335+
4336+
{ <field1>: <expression1>, ... }
4337+
4338+
The ``<field>`` can be :doc:`any field in the audit message
4339+
</reference/audit-message>`, including fields returned in the
4340+
:ref:`param <audit-action-details-results>` document. The
4341+
``<expression>`` is a :ref:`query condition expression
4342+
<query-selectors>`.
4343+
4344+
.. include:: /includes/fact-audit-filter-single-quotes.rst
4345+
4346+
.. include:: /includes/fact-audit-filter-yaml-configuration.rst
4347+
4348+
.. include:: /includes/note-audit-in-enterprise-only.rst
4349+
4350+
43254351
.. setting:: auditLog.format
43264352

43274353
*Type*: string
@@ -4353,43 +4379,24 @@ LDAP Parameters
43534379

43544380
.. include:: /includes/note-audit-in-enterprise-only.rst
43554381

4356-
43574382
.. setting:: auditLog.path
43584383

43594384
*Type*: string
43604385

43614386
The output file for :doc:`auditing </core/auditing>` if
43624387
:setting:`~auditLog.destination` has value of ``file``. The :setting:`auditLog.path`
43634388
option can take either a full path name or a relative path name.
4364-
4365-
.. include:: /includes/note-audit-in-enterprise-only.rst
43664389

4390+
.. setting:: auditLog.runtimeConfiguration
43674391

4368-
.. setting:: auditLog.filter
4369-
4370-
*Type*: string representation of a document
4371-
4372-
The filter to limit the :ref:`types of operations
4373-
<audit-action-details-results>` the :doc:`audit system
4374-
</core/auditing>` records. The option takes a string representation
4375-
of a query document of the form:
4376-
4377-
.. code-block:: javascript
4378-
4379-
{ <field1>: <expression1>, ... }
4380-
4381-
The ``<field>`` can be :doc:`any field in the audit message
4382-
</reference/audit-message>`, including fields returned in the
4383-
:ref:`param <audit-action-details-results>` document. The
4384-
``<expression>`` is a :ref:`query condition expression
4385-
<query-selectors>`.
4386-
4387-
.. include:: /includes/fact-audit-filter-single-quotes.rst
4392+
*Type*: boolean
43884393

4389-
.. include:: /includes/fact-audit-filter-yaml-configuration.rst
4394+
Specifies if a node allows runtime configuration of audit filters
4395+
and the auditAuthorizationSuccess variable. If ``true`` the node
4396+
can take part in Online Audit Filter Management.
43904397

4391-
.. include:: /includes/note-audit-in-enterprise-only.rst
43924398

4399+
.. include:: /includes/note-audit-in-enterprise-only.rst
43934400

43944401
``snmp`` Options
43954402
~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)