Navigation

Logs

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.

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

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.
LOG-NAME Required

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

  • mongod.gz

  • mongos.gz

  • mongosqld.gz

  • mongodb-audit-log.gz

  • mongos-audit-log.gz

    Note

    Audit logs are only avaiable if you have enabled Database Auditing for an Atlas project.

Request Query Parameters

Field Required/Optional Description
startDate Optional. Unix timestamp that specifies starting point for the range of log messages to retrieve. Default is 24 hours prior to the current timestamp.
endDate Optional. Unix timestamp 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 audit log for instance of mongod running on the specified host:

curl -X GET -u "{username:apiKey}" --digest -o mongod-audit-log.gz \
"https://cloud.mongodb.com/api/atlas/v1.0/groups/99999962187d9d67ca76b85f8/clusters/mycluster-shard-00-00.mongodb.net/logs/mongodb-audit-log.gz?startDate=1500249600&endDate=1500422400"

Example Response

The request downloads the log file and saves it with the name mongod-audit-log.gz.