@@ -159,8 +159,32 @@ Review the Logs
159
159
---------------
160
160
161
161
Keep and review adequate logs to help debug issues and monitor cluster
162
- activity. Use the recommended `logging architecture <https://kubernetes.io/docs/concepts/cluster-administration/logging/>`__ to retain
163
- |k8s-pod| logs even after a Pod is deleted.
162
+ activity. Use the recommended `logging architecture
163
+ <https://kubernetes.io/docs/concepts/cluster-administration/logging/>`__
164
+ to retain |k8s-pod| logs even after a Pod is deleted.
165
+
166
+ Logging Process
167
+ ~~~~~~~~~~~~~~~
168
+
169
+ The |k8s-op-short| writes to the Pod logs by using
170
+ a wrapper that converts logs from the {+mdbagent+} and |mongod|
171
+ components on the database deployment Pod into a
172
+ structured logging entry in the following |json| format:
173
+
174
+ .. code-block:: json
175
+
176
+ { "logType": "<log-type>", "contents": "<log line from a log file>" }
177
+
178
+ The |k8s-op-short| supports the following log types:
179
+
180
+ - ``automation-agent-verbose``
181
+ - ``automation-agent-stderr``
182
+ - ``mongodb``
183
+ - ``mongodb-audit``
184
+
185
+ When you read logs from a database container,
186
+ the |k8s-op-short| returns the structured |json| entry
187
+ that contains logs from different sources.
164
188
165
189
.. _review-k8s-op-logs:
166
190
@@ -193,8 +217,8 @@ To find which pods are available, invoke this command first:
193
217
.. _review-all-k8s-logs:
194
218
.. _review-one-k8s-pod:
195
219
196
- Review Logs from Specific Pod
197
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
220
+ Review Logs from a Specific Pod
221
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
198
222
199
223
If you want to narrow your review to a specific |k8s-pod|, you can
200
224
invoke this command:
@@ -214,6 +238,45 @@ invoke this command:
214
238
This returns the :ref:`Automation Agent Log <agent-logs>` for this
215
239
replica set.
216
240
241
+ Review a Specific Log
242
+ ~~~~~~~~~~~~~~~~~~~~~
243
+
244
+ You can narrow your review to a specific log type. For example,
245
+ the following command returns audit logs from the |k8s| logs
246
+ of the specified Pod by specifying the ``mongodb-audit`` log type:
247
+
248
+ .. code-block:: sh
249
+
250
+ kubectl logs -c mongodb-enterprise-database replica-set-0 | jq -r 'select(.logType == "mongodb-audit") | .contents'
251
+
252
+ The command returns an entry similar to the following output:
253
+
254
+ .. code-block:: json
255
+
256
+ {{{ "atype":"startup","ts":{"$date":"2023-08-30T20:43:54.649+00:00"},"uuid":{"$binary":"oDcPEY69R1yiUtpMupaXOQ==","$type":"04"},"local":{"isSystemUser":true},"remote":{"isSystemUser":true},"users":[],"roles":[],"param":{"options":{"auditLog":{"destination":"file","format":"JSON","path":"/var/log/mongodb-mms-automation/mongodb-audit.log"},"config":"/data/automation-mongod.conf","net":{"bindIp":"0.0.0.0","port":27017,"tls":{"mode":"disabled"}},"processManagement":{"fork":true},"replication":{"replSetName":"replica-set"},"storage":{"dbPath":"/data","engine":"wiredTiger"},"systemLog":{"destination":"file","path":"/var/log/mongodb-mms-automation/mongodb.log"}}},"result":0}
257
+ {"atype":"startup","ts":{"$date":"2023-08-30T20:44:05.466+00:00"},"uuid":{"$binary":"OUbUWC1DQM6k/Ih4hKZq4g==","$type":"04"},"local":{"isSystemUser":true},"remote":{"isSystemUser":true},"users":[],"roles":[],"param":{"options":{"auditLog":{"destination":"file","format":"JSON","path":"/var/log/mongodb-mms-automation/mongodb-audit.log"},"config":"/data/automation-mongod.conf","net":{"bindIp":"0.0.0.0","port":27017,"tls":{"mode":"disabled"}},"processManagement":{"fork":true},"replication":{"replSetName":"replica-set"},"storage":{"dbPath":"/data","engine":"wiredTiger"},"systemLog":{"destination":"file","path":"/var/log/mongodb-mms-automation/mongodb.log"}}},"result":0}}}
258
+
259
+ Audit Logs
260
+ ~~~~~~~~~~
261
+
262
+ If you want audit logs to display in the |k8s| Pod's logs, configure
263
+ your resource definition to save audit logs to the
264
+ ``/var/log/mongodb-mms-automation/mongodb-audit.log`` path:
265
+
266
+ .. code-block:: yaml
267
+
268
+ spec:
269
+ additionalMongodConfig:
270
+ auditLog:
271
+ destination: file
272
+ format: JSON
273
+ path: /var/log/mongodb-mms-automation/mongodb-audit.log
274
+
275
+ .. note::
276
+
277
+ This file path is fixed. You can't specify a different path to
278
+ save audit logs.
279
+
217
280
.. _k8s-validation-webhook:
218
281
219
282
Check Messages from the Validation Webhook
@@ -693,7 +756,7 @@ commands. This requires you to prevent the container from restarting.
693
756
694
757
kubectl exec -it <pod-name> bash
695
758
696
- Verify Corrrectness of Domain Names in TLS Certificates
759
+ Verify Correctness of Domain Names in TLS Certificates
697
760
-------------------------------------------------------
698
761
699
762
A MongoDB replica set or sharded cluster may fail to reach
0 commit comments