Navigation

Logs

Retrieves a compressed (.gz) log file that contains a range of log messages for a particular host in an Atlas cluster.

Process and audit logs are updated from the cluster backend infrastructure every five minutes and contain log data from the previous five minutes. If you are polling the API for log files, polling every five minutes is recommended.

Example

If the logs are updated at 4:00 UTC and then you poll the API, the API returns log data from the interval between 3:55 UTC and 4:00 UTC.

Note

This feature is not available for M0 (Free Tier), M2, and M5 clusters. For more information, see Atlas M0 (Free Tier), M2, and M5 Limitations.

Note

Groups and projects are synonymous terms. Your {GROUP-ID} is the same as your project ID. For existing groups, your group/project ID remains the same. The resource and corresponding endpoints use the term groups.

Important

You must be an owner of the project that the cluster belongs to in order to retrieve the log.

Base URL: https://cloud.mongodb.com/api/atlas/v1.0

Syntax

GET /groups/{GROUP-ID}/clusters/{HOSTNAME}/logs/{LOG-NAME}

Request Path Parameters

Parameter Required/Optional Description
GROUP-ID Required Project identifier.
HOSTNAME Required Name of the host where the log files that you want to download are stored. To see the hostnames of your Atlas cluster, visit the cluster overview page in the Atlas UI.
LOG-NAME Required

The name of the log file that you want to retrieve:

Request Query Parameters

Field Required/Optional Description
startDate Optional. Timestamp in the number of seconds that have elapsed since the UNIX epoch that specifies starting point for the range of log messages to retrieve. Default is 24 hours prior to the current timestamp.
endDate Optional. Timestamp in the number of seconds that have elapsed since the UNIX epoch that specifies the end point for the range of log messages to retrieve. Default is current timestamp.

Request Body Parameters

This endpoint does not use HTTP request body parameters.

Response Elements

This endpoint does not return an HTTP response body.

Example

Example Request

The following example downloads the server log for the mongod instance running on the specified host:

curl --user '{USERNAME}:{APIKEY}' --digest \
 --header 'Accept: application/gzip' \
 --request GET "https://cloud.mongodb.com/api/atlas/v1.0/groups/{GROUP-ID}/clusters/{HOSTNAME}/logs/mongodb.gz" \
 --output "mongodb.gz"

Example Response

The request downloads the log file and saves it with the name mongodb.gz.