Access Logs
Last updated
Last updated
Every running MongoDB instance collects logs from MongoD. Currently, there is no option to change this configuration. The log messages are shipped to a central storage location with a retention policy of 30 days.
Using the cluster ID, you can access the logs for that cluster via the API.
The endpoint for fetching logs has four optional query parameters:
Parameter | Description | Default value | Possible values |
---|---|---|---|
If you omit all parameters, you will get the most recent 100 log messages.
The following example shows how to receive only the first two messages after 12:00 a.m. on January 5, 2022:
The response contains the log messages separated per instance and looks similar to this:
start
Retrieve log lines after this timestamp (format: RCF3339)
30 days ago
between 30 days ago and now (before end)
end
Retrieve log line before this timestamp (format: RFC3339)
now
between 30 days ago and now (after start)
direction
Direction in which the logs are sorted and limited
BACKWARD
BACKWARD or FORWARD
limit
Maximum number of log lines to retrieve. Which log lines are cut depends on direction
100
between 1 and 5000