Skip to content

Commit 4e89479

Browse files
authored
(DOCSP-46240) Added more examples for Auditing and Logs (#110)
* (DOCSP-46240) Added more examples for Auditing and Logs * Moved API stuff under TF examples, address comments from Sarah * Updated one link, per review from Sarah
1 parent 5477601 commit 4e89479

9 files changed

+146
-38
lines changed

source/auditing-logging.txt

Lines changed: 114 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,64 +62,68 @@ Accessing Audit Logs
6262

6363
.. include:: /includes/cloud-docs/logs.rst
6464

65-
To return and update your audit configuration per project, use the following {+atlas-cli+} commands:
65+
You can review and update your auditing configuration per project. Use
66+
the following {+atlas-cli+} commands:
6667

6768
- :ref:`atlas auditing describe <atlas-auditing-describe>` returns the
6869
auditing configuration for the specified project.
6970
- :ref:`atlas auditing update <atlas-auditing-update>` updates
7071
the auditing configuration for the specified project.
7172

72-
You can :ref:`view authentication attempts <access-tracking>` that users
73-
make against your {+cluster+} with the {+atlas-cli+},
74-
{+atlas-admin-api+}, or {+atlas-ui+}. |service| logs both successful and unsuccessful
75-
authentication attempts, including the timestamp of each attempt and which
76-
user tried to authenticate.
73+
You can :ref:`view authentication attempts <access-tracking>` that users make
74+
against your {+cluster+} with the {+atlas-cli+}, {+atlas-admin-api+}, or {+atlas-ui+}.
75+
|service| logs both successful and unsuccessful authentication attempts,
76+
including the timestamp of each attempt and which user tried to authenticate.
7777

7878
You can also :ref:`view and filter the activity feed <view-activity-feed>`
79-
for an organization or project with the {+atlas-cli+},
80-
{+atlas-admin-api+}, or {+atlas-ui+}. The activity feed lists all
81-
events at the organization or project level.
79+
for an organization or project with the {+atlas-cli+}, {+atlas-admin-api+},
80+
or {+atlas-ui+}. The activity feed lists all events at the organization or project level.
8281

8382
To perform a full audit, you can use a combination of audit logs,
84-
the ``mongodb.log``, and :ref:`the project and organization activity feed <view-activity-feed>`.
83+
:manual:`MongoDB log messages </reference/log-messages/>`, and
84+
:ref:`the project and organization activity feed <view-activity-feed>`.
8585

8686
Recommendations for Auditing
8787
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8888

89-
We recommend that you enable auditing when you provision your {+clusters+}.
90-
However, auditing puts additional load on your {+clusters+} and increases costs.
89+
We recommend that you :atlas:`set up database auditing </database-auditing>`
90+
when you provision your {+clusters+}.
91+
Auditing puts additional load on your {+clusters+} and increases costs.
9192
To optimize costs, you can disable auditing in lower environments for development.
92-
Certain industries, like healthcare and financial services, may opt to keep
93-
auditing enabled in development for compliance reasons.
93+
Certain industries, such as healthcare and financial services, may opt to keep
94+
auditing enabled in development environments for compliance reasons.
9495

9596
Enabling auditing for all database users, including application
96-
service users, might affect cluster performance. We recommend that you audit only the actions of users that require auditing.
97+
service users, might affect cluster performance. We recommend that you
98+
audit only the actions of users that require auditing.
9799

98100
For staging and production environments, enable auditing for
99-
additional security. We recommend that you audit the following events at a minimum:
101+
additional security.
102+
103+
We recommend that you audit the following events at a minimum:
100104

101105
- Failed logon
102106
- Session activity
103107
- Logon and logoff
104108
- Attempts to perform unauthorized functions
105109
- Password change
106-
- Database User Access Changes
110+
- Database User Access changes
107111
- DDL & System configuration stored procedures
108112
- Modification of Native audit
109-
- Run a backup or restore
110-
- Alter DBMS native audit settings
111-
- Alter security
112-
- Database Start and Stop Commands
113+
- Running a backup or restore operation
114+
- Altering DBMS native audit settings
115+
- Altering security
116+
- Running database start and stop commands
113117

114-
For all of the previous events, you should include the following
118+
For all of the previous events, you should include in the audit log the following
115119
information at a minimum:
116120

117121
- Session ID
118122
- Client hostname and IP address
119123
- Database server hostname and IP address
120124
- Database user
121-
- OS user
122125
- Database name
126+
- OS user
123127
- Service/instance name
124128
- Port
125129
- Application
@@ -133,24 +137,23 @@ Recommendations for Programmatic Access to Audit Logs
133137
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
134138

135139
To integrate with tools beyond the built-in integrations, we recommend
136-
that you retrieve logs with the following programmatic tools and feed the JSON-formatted output to your external tools:
137-
138-
- If you use |aws|, you can continually push logs to an |aws| S3
139-
bucket. To learn more, see the
140-
:oas-atlas-tag:`Push-Based Log Export <Push-Based-Log-Export>` {+atlas-admin-api+} endpoints.
141-
- Use the {+atlas-admin-api+} endpoints for :oas-atlas-tag:`Logs <MongoDB-Cloud-Users>` and :oas-atlas-tag:`Project and Organization Events <Events>` to
142-
retrieve deployment logs and lists of project events.
143-
- Use the ``atlas deployments logs`` command in the {+atlas-cli+}
144-
to retrieve deployment logs. To learn more,
145-
see :atlas:`Atlas Deployment Logs
146-
</cli/current/command/atlas-deployments-logs/>`.
140+
that you retrieve logs with the following programmatic tools and feed
141+
the JSON-formatted output to your external tools:
142+
143+
- To continually push logs to an |aws| |s3| bucket, use the {+atlas-admin-api+}
144+
endpoints for :oas-atlas-tag:`Push-Based Log Export <Push-Based-Log-Export>`.
145+
- To retrieve deployment logs and lists of project events,
146+
use the {+atlas-admin-api+} endpoints for :oas-atlas-tag:`Logs <MongoDB-Cloud-Users>`
147+
and :oas-atlas-tag:`Project and Organization Events <Events>`.
148+
- To retrieve deployment logs, use :ref:`atlas deployment logs <atlas-deployments-logs>`
149+
command in the {+atlas-cli+}. To learn more, see :atlas:`Atlas Deployment Logs </cli/current/command/atlas-deployments-logs/>`.
147150

148151
Examples
149152
--------
150153

151154
.. include:: /includes/complete-examples.rst
152155

153-
The following examples show how to download logs and enable auditing
156+
The following examples show how to retrieve and download logs and configure auditing
154157
using |service| :ref:`tools for automation <arch-center-automation>`.
155158

156159
In addition to the following examples, see the blogpost
@@ -161,11 +164,66 @@ In addition to the following examples, see the blogpost
161164
.. tab:: CLI
162165
:tabid: cli
163166

167+
Update Audit Configuration
168+
~~~~~~~~~~~~~~~~~~~~~~~~~~
169+
170+
Run the following {+atlas-cli+} command to audit all authentication events
171+
for known users in your project:
172+
173+
.. include:: /includes/examples/cli-example-audit-logs-known-users.rst
174+
175+
Run the following {+atlas-cli+} command to audit a known user
176+
via a configuration file:
177+
178+
.. include:: /includes/examples/cli-example-audit-logs-config-file.rst
179+
180+
Describe Audit Configuration
181+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182+
183+
Run the :ref:`atlas auditing describe <atlas-auditing-describe>`
184+
{+atlas-cli+} command to return the auditing configuration for the specified project:
185+
186+
.. include:: /includes/examples/cli-example-audit-logs-describe.rst
187+
188+
Create and Use Audit Filter
189+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
190+
191+
Create an audit filter to only audit the authenticate operations
192+
that occur against the test database. To learn more,
193+
see :manual:`Configure Audit Filters </tutorial/configure-audit-filters/>`.
194+
195+
.. include:: /includes/examples/cli-example-audit-filter.rst
196+
197+
To use an audit filter that you created, update the audit configuration
198+
using the :ref:`atlas auditing update <atlas-auditing-describe>`
199+
{+atlas-cli+} command:
200+
201+
.. include:: /includes/examples/cli-example-audit-filter-use.rst
202+
203+
Retrieve Logs
204+
~~~~~~~~~~~~~
205+
206+
To retrieve the access log, use a command similar to the following.
207+
This command returns a JSON-formatted list of all authentication
208+
requests made against the {+clusters+} named ``Cluster0`` for the project
209+
with the ID ``618d48e05277a606ed2496fe``:
210+
211+
.. include:: /includes/examples/cli-example-retrieve-logs.rst
212+
213+
Retrieve All Log Events for Organization in a JSON File
214+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215+
216+
To return all events for the specified organization, use a command
217+
similar to the following. This command returns a JSON-formatted list
218+
of events for the organization with the ID ``5dd5a6b6f10fab1d71a58495``:
219+
220+
.. include:: /includes/examples/cli-example-retrieve-logs-org.rst
221+
164222
Download Logs
165223
~~~~~~~~~~~~~
166224

167-
Run the following CLI command to download a compressed file that contains the
168-
MongoDB logs for the specified host in your project.
225+
Run the following {+atlas-cli+} command to download a compressed file that
226+
contains the MongoDB logs for the specified host in your project.
169227

170228
.. include:: /includes/examples/cli-example-download-logs.rst
171229

@@ -191,4 +249,23 @@ In addition to the following examples, see the blogpost
191249
Enable Auditing and Create an Auditing Filter for the {+Cluster+}
192250
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
193251

252+
You can :manual:`configure manual auditing </core/auditing>` of most of the
253+
documented :manual:`system event actions </reference/audit-message/mongo/>`
254+
by creating audit filters. To learn more about configuring audit filters,
255+
see :manual:`Configure Audit Filters </tutorial/configure-audit-filters/>`.
256+
194257
.. include:: /includes/examples/tf-example-auditing-filter.rst
258+
259+
Retrieve Logs
260+
~~~~~~~~~~~~~
261+
262+
You can't retrieve logs with Terraform. Instead, use the following
263+
{+atlas-admin-api+} endpoints:
264+
265+
- Use :oas-atlas-tag:`Access Tracking Admin API </Access-Tracking>`
266+
to return access logs for all authentication attempts for the database,
267+
identified by the cluster's name or hostname.
268+
269+
- Use :oas-atlas-tag:`Monitoring and Logs APIs </Monitoring-and-Logs>`
270+
to retrieve a compressed log file with log messages for the specified
271+
host.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas auditing update --auditFilter '{"atype": "authenticate", "param.db": "test"}'
5+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
{ atype: "authenticate", "param.db": "test" }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas auditing update -f filter.json
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas auditing describe --output json
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas auditing update --auditFilter '{"atype": "authenticate"}'
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas events organizations list --orgId 5dd5a6b6f10fab1d71a58495 --output json
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.. code-block::
2+
:copyable: true
3+
4+
atlas accesslogs list --output json --projectId 618d48e05277a606ed2496fe --clusterName Cluster0
5+

source/landing-zone.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ applicable only to |aws| and |azure|.
266266

267267
To identify more considerations and requirements specific to your
268268
organization, see the previous section on
269-
:ref:`landing-zone-considerations`.
269+
:ref:`Landing Zone Considerations <landing-zone-considerations>`.
270270

271271
Next Steps
272272
----------

0 commit comments

Comments
 (0)